mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 15:44:36 +00:00
Path class augs
adds the following behaviours: onPostAdd, send an updatePath event so that paths created post-pathOnMissionLoadDone command can register with clients (like say when they are loaded from a submis) for editing tool purposes, allow Path::SetTransform to impact child objects so that pre-existing ones can be copy/pasted without the markers ending up in the same spot, or so that you can shift the entire path around and have those move in a relative manner
This commit is contained in:
parent
0ebb2e9115
commit
db42149fb5
2 changed files with 45 additions and 0 deletions
|
|
@ -35,6 +35,7 @@
|
||||||
#include "renderInstance/renderPassManager.h"
|
#include "renderInstance/renderPassManager.h"
|
||||||
#include "console/engineAPI.h"
|
#include "console/engineAPI.h"
|
||||||
#include "T3D/pathShape.h"
|
#include "T3D/pathShape.h"
|
||||||
|
#include "T3D/physics/physicsShape.h"
|
||||||
|
|
||||||
#include "T3D/Scene.h"
|
#include "T3D/Scene.h"
|
||||||
|
|
||||||
|
|
@ -197,6 +198,12 @@ bool Path::onAdd()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Path::onPostAdd()
|
||||||
|
{
|
||||||
|
Parent::onPostAdd();
|
||||||
|
if (isServerObject())
|
||||||
|
updatePath();
|
||||||
|
}
|
||||||
IMPLEMENT_CALLBACK(Path, onAdd, void, (SimObjectId ID), (ID),
|
IMPLEMENT_CALLBACK(Path, onAdd, void, (SimObjectId ID), (ID),
|
||||||
"Called when this ScriptGroup is added to the system.\n"
|
"Called when this ScriptGroup is added to the system.\n"
|
||||||
"@param ID Unique object ID assigned when created (%this in script).\n"
|
"@param ID Unique object ID assigned when created (%this in script).\n"
|
||||||
|
|
@ -252,6 +259,42 @@ void Path::updatePath()
|
||||||
gServerPathManager->updatePath(mPathIndex, positions, rotations, times, smoothingTypes, mIsLooping);
|
gServerPathManager->updatePath(mPathIndex, positions, rotations, times, smoothingTypes, mIsLooping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Path::setTransform(const MatrixF& mat)
|
||||||
|
{
|
||||||
|
if (isServerObject())
|
||||||
|
{
|
||||||
|
MatrixF newXform = mat;
|
||||||
|
MatrixF oldXform = getTransform();
|
||||||
|
oldXform.affineInverse();
|
||||||
|
|
||||||
|
MatrixF offset;
|
||||||
|
offset.mul(newXform, oldXform);
|
||||||
|
|
||||||
|
// Update all child transforms
|
||||||
|
for (SimSetIterator itr(this); *itr; ++itr)
|
||||||
|
{
|
||||||
|
SceneObject* child = dynamic_cast<SceneObject*>(*itr);
|
||||||
|
if (child)
|
||||||
|
{
|
||||||
|
MatrixF childMat;
|
||||||
|
|
||||||
|
//add the "offset" caused by the parents change, and add it to it's own
|
||||||
|
// This is needed by objects that update their own render transform thru interpolate tick
|
||||||
|
// Mostly for stationary objects.
|
||||||
|
childMat.mul(offset, child->getTransform());
|
||||||
|
child->setTransform(childMat);
|
||||||
|
|
||||||
|
PhysicsShape* childPS = dynamic_cast<PhysicsShape*>(child);
|
||||||
|
if (childPS)
|
||||||
|
childPS->storeRestorePos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updatePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
Parent::setTransform(mat);
|
||||||
|
}
|
||||||
|
|
||||||
void Path::addObject(SimObject* obj)
|
void Path::addObject(SimObject* obj)
|
||||||
{
|
{
|
||||||
Parent::addObject(obj);
|
Parent::addObject(obj);
|
||||||
|
|
|
||||||
|
|
@ -76,12 +76,14 @@ class Path : public GameBase
|
||||||
~Path();
|
~Path();
|
||||||
|
|
||||||
void addObject(SimObject*) override;
|
void addObject(SimObject*) override;
|
||||||
|
void onPostAdd() override;
|
||||||
void removeObject(SimObject*) override;
|
void removeObject(SimObject*) override;
|
||||||
|
|
||||||
void sortMarkers();
|
void sortMarkers();
|
||||||
void updatePath();
|
void updatePath();
|
||||||
bool isLooping() { return mIsLooping; }
|
bool isLooping() { return mIsLooping; }
|
||||||
U32 getPathIndex() const;
|
U32 getPathIndex() const;
|
||||||
|
void setTransform(const MatrixF& mat) override;
|
||||||
|
|
||||||
DECLARE_CONOBJECT(Path);
|
DECLARE_CONOBJECT(Path);
|
||||||
DECLARE_CATEGORY("Cinematic");
|
DECLARE_CATEGORY("Cinematic");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue