mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
Core/Misc: update g3dlite lib (#2904)
* Core/Misc: update g3dlite lib * update Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
This commit is contained in:
40
deps/g3dlite/source/PhysicsFrame.cpp
vendored
40
deps/g3dlite/source/PhysicsFrame.cpp
vendored
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
@file PhysicsFrame.cpp
|
||||
\file PhysicsFrame.cpp
|
||||
|
||||
@maintainer Morgan McGuire, http://graphics.cs.williams.edu
|
||||
\maintainer Morgan McGuire, http://graphics.cs.williams.edu
|
||||
|
||||
@created 2002-07-09
|
||||
@edited 2010-03-25
|
||||
\created 2002-07-09
|
||||
\edited 2013-04-25
|
||||
*/
|
||||
|
||||
#include "G3D/platform.h"
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "G3D/PhysicsFrame.h"
|
||||
#include "G3D/BinaryInput.h"
|
||||
#include "G3D/BinaryOutput.h"
|
||||
#include "G3D/UprightFrame.h"
|
||||
|
||||
namespace G3D {
|
||||
|
||||
@@ -22,31 +23,44 @@ PhysicsFrame::PhysicsFrame() {
|
||||
}
|
||||
|
||||
|
||||
PhysicsFrame::PhysicsFrame(
|
||||
const CoordinateFrame& coordinateFrame) {
|
||||
|
||||
PhysicsFrame::PhysicsFrame
|
||||
(const CoordinateFrame& coordinateFrame) {
|
||||
translation = coordinateFrame.translation;
|
||||
rotation = Quat(coordinateFrame.rotation);
|
||||
}
|
||||
|
||||
|
||||
Any PhysicsFrame::toAny() const {
|
||||
// Prefer to serialize as a CFrame, which is easier to read
|
||||
if (false) {
|
||||
Any a(Any::ARRAY, "PFrame");
|
||||
a.append(rotation, translation.toAny("Point3"));
|
||||
return a;
|
||||
} else {
|
||||
return CFrame(*this).toAny();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PhysicsFrame::PhysicsFrame(const Any& a) {
|
||||
const std::string& n = toLower(a.name());
|
||||
*this = PhysicsFrame();
|
||||
|
||||
if (beginsWith(n, "vector3")) {
|
||||
*this = PhysicsFrame(Vector3(a));
|
||||
if (beginsWith(n, "vector3") || beginsWith(n, "point3")) {
|
||||
*this = PhysicsFrame(Point3(a));
|
||||
} else if (beginsWith(n, "matrix3")) {
|
||||
*this = PhysicsFrame(Matrix3(a));
|
||||
} else if (beginsWith(n, "cframe") || beginsWith(n, "coordinateframe")) {
|
||||
*this = PhysicsFrame(CoordinateFrame(a));
|
||||
} else if (beginsWith(n, "cframe") || beginsWith(n, "coordinateframe") || beginsWith(n, "matrix4")) {
|
||||
*this = CoordinateFrame(a);
|
||||
} else if (beginsWith(n, "uprightframe")) {
|
||||
*this = UprightFrame(a).toCoordinateFrame();
|
||||
} else if (beginsWith(n, "pframe") || beginsWith(n, "physicsframe")) {
|
||||
if (a.type() == Any::ARRAY) {
|
||||
a.verifySize(2);
|
||||
rotation = a[0];
|
||||
translation = a[1];
|
||||
} else {
|
||||
for (Any::AnyTable::Iterator it = a.table().begin(); it.hasMore(); ++it) {
|
||||
for (Any::AnyTable::Iterator it = a.table().begin(); it.isValid(); ++it) {
|
||||
const std::string& n = toLower(it->key);
|
||||
if (n == "translation") {
|
||||
translation = it->value;
|
||||
@@ -57,6 +71,8 @@ PhysicsFrame::PhysicsFrame(const Any& a) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
a.verify(false, "Unrecognized class name where a PhysicsFrame or equivalent was expected.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user