mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-17 01:04:34 +00: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:
75
deps/g3dlite/source/PhysicsFrameSpline.cpp
vendored
75
deps/g3dlite/source/PhysicsFrameSpline.cpp
vendored
@@ -6,55 +6,53 @@
|
||||
#include "G3D/PhysicsFrameSpline.h"
|
||||
#include "G3D/Any.h"
|
||||
#include "G3D/stringutils.h"
|
||||
#include "G3D/UprightFrame.h"
|
||||
|
||||
namespace G3D {
|
||||
|
||||
PhysicsFrameSpline::PhysicsFrameSpline() {}
|
||||
|
||||
|
||||
PhysicsFrameSpline::PhysicsFrameSpline(const Any& any) {
|
||||
*this = any;
|
||||
if (beginsWith(any.name(), "PFrameSpline") ||
|
||||
beginsWith(any.name(), "PhysicsFrameSpline") ||
|
||||
beginsWith(any.name(), "CFrameSpline") ||
|
||||
beginsWith(any.name(), "CoordinateFrameSpline") ||
|
||||
beginsWith(any.name(), "UprightSpline") ||
|
||||
beginsWith(any.name(), "UprightFrameSpline")) {
|
||||
AnyTableReader t(any);
|
||||
init(t);
|
||||
t.verifyDone();
|
||||
} else {
|
||||
// Must be a single control point
|
||||
control.append(any);
|
||||
time.append(0);
|
||||
}
|
||||
}
|
||||
|
||||
PhysicsFrameSpline& PhysicsFrameSpline::operator=(const Any& any) {
|
||||
const std::string& n = toLower(any.name());
|
||||
*this = PhysicsFrameSpline();
|
||||
|
||||
if (n == "physicsframespline" || n == "pframespline") {
|
||||
any.verifyName("PhysicsFrameSpline", "PFrameSpline");
|
||||
|
||||
for (Any::AnyTable::Iterator it = any.table().begin(); it.hasMore(); ++it) {
|
||||
const std::string& k = toLower(it->key);
|
||||
if (k == "cyclic") {
|
||||
cyclic = it->value;
|
||||
} else if (k == "control") {
|
||||
const Any& v = it->value;
|
||||
v.verifyType(Any::ARRAY);
|
||||
control.resize(v.size());
|
||||
for (int i = 0; i < control.size(); ++i) {
|
||||
control[i] = v[i];
|
||||
}
|
||||
if (! any.containsKey("time")) {
|
||||
time.resize(control.size());
|
||||
for (int i = 0; i < time.size(); ++i) {
|
||||
time[i] = i;
|
||||
}
|
||||
}
|
||||
} else if (k == "finalinterval") {
|
||||
finalInterval = it->value;
|
||||
} else if (k == "time") {
|
||||
const Any& v = it->value;
|
||||
v.verifyType(Any::ARRAY);
|
||||
time.resize(v.size());
|
||||
for (int i = 0; i < time.size(); ++i) {
|
||||
time[i] = v[i];
|
||||
}
|
||||
bool PhysicsFrameSpline::operator==(const PhysicsFrameSpline& other) const {
|
||||
if ((extrapolationMode == other.extrapolationMode) &&
|
||||
(time.size() == other.size()) &&
|
||||
(finalInterval == other.finalInterval) &&
|
||||
(control.size() == other.control.size())) {
|
||||
// Check actual values
|
||||
for (int i = 0; i < time.size(); ++i) {
|
||||
if (time[i] != other.time[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < control.size(); ++i) {
|
||||
if (control[i] != other.control[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// Must be a PhysicsFrame constructor of some kind
|
||||
append(any);
|
||||
return false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +60,11 @@ void PhysicsFrameSpline::correct(PhysicsFrame& frame) const {
|
||||
frame.rotation.unitize();
|
||||
}
|
||||
|
||||
void PhysicsFrameSpline::scaleControlPoints(float scaleFactor) {
|
||||
for (int i = 0; i < control.size(); ++i) {
|
||||
control[i].translation *= scaleFactor;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsFrameSpline::ensureShortestPath(PhysicsFrame* A, int N) const {
|
||||
for (int i = 1; i < N; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user