mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Some code cleanup, tweak and optimizations for assets, entities and components.
This commit is contained in:
parent
cfbdf63cd7
commit
abe4370c8a
15 changed files with 58 additions and 40 deletions
|
|
@ -90,14 +90,9 @@ ConsoleSetType(TypeImageAssetPtr)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ImageAsset::ImageAsset()
|
ImageAsset::ImageAsset() : AssetBase(), mImage(nullptr), mUseMips(true), mIsHDRImage(false), mIsValidImage(false)
|
||||||
{
|
{
|
||||||
mImageFileName = StringTable->EmptyString();
|
mImageFileName = StringTable->EmptyString();
|
||||||
|
|
||||||
mImage = NULL;
|
|
||||||
mUseMips = true;
|
|
||||||
mIsHDRImage = false;
|
|
||||||
mIsValidImage = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,6 @@ class ImageAsset : public AssetBase
|
||||||
{
|
{
|
||||||
typedef AssetBase Parent;
|
typedef AssetBase Parent;
|
||||||
|
|
||||||
AssetManager* mpOwningAssetManager;
|
|
||||||
bool mAssetInitialized;
|
|
||||||
AssetDefinition* mpAssetDefinition;
|
|
||||||
U32 mAcquireReferenceCount;
|
|
||||||
|
|
||||||
StringTableEntry mImageFileName;
|
StringTableEntry mImageFileName;
|
||||||
|
|
||||||
GFXTexHandle mImage;
|
GFXTexHandle mImage;
|
||||||
|
|
|
||||||
|
|
@ -90,10 +90,12 @@ ConsoleSetType(TypeLevelAssetPtr)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
LevelAsset::LevelAsset()
|
LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
|
||||||
{
|
{
|
||||||
mLevelFile = StringTable->EmptyString();
|
mLevelFile = StringTable->EmptyString();
|
||||||
mPreviewImage = StringTable->EmptyString();
|
mPreviewImage = StringTable->EmptyString();
|
||||||
|
|
||||||
|
mMainLevelAsset = StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ ConsoleSetType(TypeScriptAssetPtr)
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
ScriptAsset::ScriptAsset()
|
ScriptAsset::ScriptAsset() : AssetBase(), mIsServerSide(true)
|
||||||
{
|
{
|
||||||
mScriptFilePath = StringTable->EmptyString();
|
mScriptFilePath = StringTable->EmptyString();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -613,6 +613,9 @@ void AnimationComponent::advanceThreads(F32 dt)
|
||||||
if (!mOwnerRenderInst)
|
if (!mOwnerRenderInst)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (mOwnerShapeInstance == nullptr || !getShape())
|
||||||
|
return;
|
||||||
|
|
||||||
for (U32 i = 0; i < MaxScriptThreads; i++)
|
for (U32 i = 0; i < MaxScriptThreads; i++)
|
||||||
{
|
{
|
||||||
Thread& st = mAnimationThreads[i];
|
Thread& st = mAnimationThreads[i];
|
||||||
|
|
|
||||||
|
|
@ -142,10 +142,12 @@ CollisionComponent::CollisionComponent() : Component()
|
||||||
StaticShapeObjectType | VehicleObjectType |
|
StaticShapeObjectType | VehicleObjectType |
|
||||||
VehicleBlockerObjectType | DynamicShapeObjectType | StaticObjectType | EntityObjectType | TriggerObjectType);
|
VehicleBlockerObjectType | DynamicShapeObjectType | StaticObjectType | EntityObjectType | TriggerObjectType);
|
||||||
|
|
||||||
mPhysicsRep = NULL;
|
mPhysicsRep = nullptr;
|
||||||
mPhysicsWorld = NULL;
|
mPhysicsWorld = nullptr;
|
||||||
|
|
||||||
mTimeoutList = NULL;
|
mTimeoutList = nullptr;
|
||||||
|
|
||||||
|
mAnimated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CollisionComponent::~CollisionComponent()
|
CollisionComponent::~CollisionComponent()
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,13 @@ Component::Component()
|
||||||
mOriginatingAssetId = StringTable->EmptyString();
|
mOriginatingAssetId = StringTable->EmptyString();
|
||||||
|
|
||||||
mIsServerObject = true;
|
mIsServerObject = true;
|
||||||
|
|
||||||
|
componentIdx = 0;
|
||||||
|
|
||||||
|
mHidden = false;
|
||||||
|
mEnabled = true;
|
||||||
|
|
||||||
|
mDirtyMaskBits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component::~Component()
|
Component::~Component()
|
||||||
|
|
@ -535,7 +542,7 @@ const char * Component::getDescriptionText(const char *desc)
|
||||||
if (desc == NULL)
|
if (desc == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char *newDesc;
|
char *newDesc = "";
|
||||||
|
|
||||||
// [tom, 1/12/2007] If it isn't a file, just do it the easy way
|
// [tom, 1/12/2007] If it isn't a file, just do it the easy way
|
||||||
if (!Platform::isFile(desc))
|
if (!Platform::isFile(desc))
|
||||||
|
|
@ -568,7 +575,7 @@ const char * Component::getDescriptionText(const char *desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
str.close();
|
str.close();
|
||||||
delete stream;
|
//delete stream;
|
||||||
|
|
||||||
return newDesc;
|
return newDesc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ StateMachine::StateMachine()
|
||||||
mStartingState = "";
|
mStartingState = "";
|
||||||
|
|
||||||
mCurCreateState = NULL;
|
mCurCreateState = NULL;
|
||||||
|
|
||||||
|
mStateMachineFile = StringTable->EmptyString();
|
||||||
|
|
||||||
|
mCurCreateState = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
StateMachine::~StateMachine()
|
StateMachine::~StateMachine()
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,8 @@ public:
|
||||||
{
|
{
|
||||||
if (index <= mFields.size())
|
if (index <= mFields.size())
|
||||||
return mFields[index];
|
return mFields[index];
|
||||||
|
|
||||||
|
return StateField(); //return a blank one
|
||||||
}
|
}
|
||||||
|
|
||||||
Signal< void(StateMachine*, S32 stateIdx) > onStateChanged;
|
Signal< void(StateMachine*, S32 stateIdx) > onStateChanged;
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,11 @@ PlayerControllerComponent::PlayerControllerComponent() : Component()
|
||||||
|
|
||||||
mInputVelocity = Point3F(0, 0, 0);
|
mInputVelocity = Point3F(0, 0, 0);
|
||||||
|
|
||||||
mPhysicsRep = NULL;
|
mPhysicsRep = nullptr;
|
||||||
mPhysicsWorld = NULL;
|
mPhysicsWorld = nullptr;
|
||||||
|
|
||||||
|
mOwnerCollisionInterface = nullptr;
|
||||||
|
mIntegrationCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerControllerComponent::~PlayerControllerComponent()
|
PlayerControllerComponent::~PlayerControllerComponent()
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ ImplementEnumType(BatchingMode,
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor/Destructor
|
// Constructor/Destructor
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
MeshComponent::MeshComponent() : Component()
|
MeshComponent::MeshComponent() : Component(), mShape(nullptr), mRenderMode(Individual)
|
||||||
{
|
{
|
||||||
mFriendlyName = "Mesh Component";
|
mFriendlyName = "Mesh Component";
|
||||||
mComponentType = "Render";
|
mComponentType = "Render";
|
||||||
|
|
|
||||||
|
|
@ -850,7 +850,7 @@ void Entity::setTransform(const MatrixF &mat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setTransform(Point3F position, RotationF rotation)
|
void Entity::setTransform(const Point3F& position, const RotationF& rotation)
|
||||||
{
|
{
|
||||||
MatrixF oldTransform = getTransform();
|
MatrixF oldTransform = getTransform();
|
||||||
|
|
||||||
|
|
@ -922,7 +922,7 @@ void Entity::setRenderTransform(const MatrixF &mat)
|
||||||
Parent::setRenderTransform(mat);
|
Parent::setRenderTransform(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setRenderTransform(Point3F position, RotationF rotation)
|
void Entity::setRenderTransform(const Point3F& position, const RotationF& rotation)
|
||||||
{
|
{
|
||||||
if (isMounted())
|
if (isMounted())
|
||||||
{
|
{
|
||||||
|
|
@ -977,7 +977,7 @@ MatrixF Entity::getTransform()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setMountOffset(Point3F posOffset)
|
void Entity::setMountOffset(const Point3F& posOffset)
|
||||||
{
|
{
|
||||||
if (isMounted())
|
if (isMounted())
|
||||||
{
|
{
|
||||||
|
|
@ -987,7 +987,7 @@ void Entity::setMountOffset(Point3F posOffset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::setMountRotation(EulerF rotOffset)
|
void Entity::setMountRotation(const EulerF& rotOffset)
|
||||||
{
|
{
|
||||||
if (isMounted())
|
if (isMounted())
|
||||||
{
|
{
|
||||||
|
|
@ -1111,11 +1111,12 @@ bool Entity::castRayRendered(const Point3F &start, const Point3F &end, RayInfo *
|
||||||
|
|
||||||
bool Entity::buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF &sphere)
|
bool Entity::buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF &sphere)
|
||||||
{
|
{
|
||||||
Vector<BuildPolyListInterface*> updaters = getComponents<BuildPolyListInterface>();
|
Con::errorf("Build Poly List not yet implemented as a passthrough for Entity");
|
||||||
|
/*Vector<BuildPolyListInterface*> updaters = getComponents<BuildPolyListInterface>();
|
||||||
for (Vector<BuildPolyListInterface*>::iterator it = updaters.begin(); it != updaters.end(); it++)
|
for (Vector<BuildPolyListInterface*>::iterator it = updaters.begin(); it != updaters.end(); it++)
|
||||||
{
|
{
|
||||||
return (*it)->buildPolyList(context, polyList, box, sphere);
|
return (*it)->buildPolyList(context, polyList, box, sphere);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1131,7 +1132,7 @@ void Entity::buildConvex(const Box3F& box, Convex* convex)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Mounting and heirarchy manipulation
|
// Mounting and heirarchy manipulation
|
||||||
void Entity::mountObject(SceneObject* objB, MatrixF txfm)
|
void Entity::mountObject(SceneObject* objB, const MatrixF& txfm)
|
||||||
{
|
{
|
||||||
Parent::mountObject(objB, -1, txfm);
|
Parent::mountObject(objB, -1, txfm);
|
||||||
Parent::addObject(objB);
|
Parent::addObject(objB);
|
||||||
|
|
@ -1604,7 +1605,7 @@ void Entity::onCameraScopeQuery(NetConnection* connection, CameraScopeQuery* que
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void Entity::setObjectBox(Box3F objBox)
|
void Entity::setObjectBox(const Box3F& objBox)
|
||||||
{
|
{
|
||||||
mObjBox = objBox;
|
mObjBox = objBox;
|
||||||
resetWorldBox();
|
resetWorldBox();
|
||||||
|
|
@ -1705,8 +1706,8 @@ void Entity::setComponentDirty(Component *comp, bool forceUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
//if (!found)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
//if(mToLoadComponents.empty())
|
//if(mToLoadComponents.empty())
|
||||||
// mStartComponentUpdate = true;
|
// mStartComponentUpdate = true;
|
||||||
|
|
|
||||||
|
|
@ -152,14 +152,14 @@ public:
|
||||||
virtual void setTransform(const MatrixF &mat);
|
virtual void setTransform(const MatrixF &mat);
|
||||||
virtual void setRenderTransform(const MatrixF &mat);
|
virtual void setRenderTransform(const MatrixF &mat);
|
||||||
|
|
||||||
void setTransform(Point3F position, RotationF rotation);
|
void setTransform(const Point3F& position, const RotationF& rotation);
|
||||||
|
|
||||||
void setRenderTransform(Point3F position, RotationF rotation);
|
void setRenderTransform(const Point3F& position, const RotationF& rotation);
|
||||||
|
|
||||||
virtual MatrixF getTransform();
|
virtual MatrixF getTransform();
|
||||||
virtual Point3F getPosition() const { return mPos; }
|
virtual Point3F getPosition() const { return mPos; }
|
||||||
|
|
||||||
void setRotation(RotationF rotation) {
|
void setRotation(const RotationF& rotation) {
|
||||||
mRot = rotation;
|
mRot = rotation;
|
||||||
setMaskBits(TransformMask);
|
setMaskBits(TransformMask);
|
||||||
};
|
};
|
||||||
|
|
@ -167,8 +167,8 @@ public:
|
||||||
|
|
||||||
static bool _setGameObject(void *object, const char *index, const char *data);
|
static bool _setGameObject(void *object, const char *index, const char *data);
|
||||||
|
|
||||||
void setMountOffset(Point3F posOffset);
|
void setMountOffset(const Point3F& posOffset);
|
||||||
void setMountRotation(EulerF rotOffset);
|
void setMountRotation(const EulerF& rotOffset);
|
||||||
|
|
||||||
//static bool _setEulerRotation( void *object, const char *index, const char *data );
|
//static bool _setEulerRotation( void *object, const char *index, const char *data );
|
||||||
static bool _setPosition(void *object, const char *index, const char *data);
|
static bool _setPosition(void *object, const char *index, const char *data);
|
||||||
|
|
@ -181,7 +181,7 @@ public:
|
||||||
virtual void getRenderMountTransform(F32 delta, S32 index, const MatrixF &xfm, MatrixF *outMat);
|
virtual void getRenderMountTransform(F32 delta, S32 index, const MatrixF &xfm, MatrixF *outMat);
|
||||||
|
|
||||||
virtual void mountObject(SceneObject *obj, S32 node, const MatrixF &xfm = MatrixF::Identity);
|
virtual void mountObject(SceneObject *obj, S32 node, const MatrixF &xfm = MatrixF::Identity);
|
||||||
void mountObject(SceneObject* objB, MatrixF txfm);
|
void mountObject(SceneObject* objB, const MatrixF& txfm);
|
||||||
void onMount(SceneObject *obj, S32 node);
|
void onMount(SceneObject *obj, S32 node);
|
||||||
void onUnmount(SceneObject *obj, S32 node);
|
void onUnmount(SceneObject *obj, S32 node);
|
||||||
|
|
||||||
|
|
@ -218,7 +218,7 @@ public:
|
||||||
return mComponents.size();
|
return mComponents.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setObjectBox(Box3F objBox);
|
virtual void setObjectBox(const Box3F& objBox);
|
||||||
|
|
||||||
void resetWorldBox() { Parent::resetWorldBox(); }
|
void resetWorldBox() { Parent::resetWorldBox(); }
|
||||||
void resetObjectBox() { Parent::resetObjectBox(); }
|
void resetObjectBox() { Parent::resetObjectBox(); }
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ Vector<MeshRenderSystem::BufferSet> MeshRenderSystem::mStaticBuffers(0);
|
||||||
|
|
||||||
void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* state)
|
void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* state)
|
||||||
{
|
{
|
||||||
|
if (sceneManager == nullptr || state == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
Frustum viewFrustum = state->getCullingFrustum();
|
Frustum viewFrustum = state->getCullingFrustum();
|
||||||
MatrixF camTransform = state->getCameraTransform();
|
MatrixF camTransform = state->getCameraTransform();
|
||||||
|
|
||||||
|
|
@ -129,7 +132,7 @@ void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* stat
|
||||||
|
|
||||||
// We sort by the material then vertex buffer
|
// We sort by the material then vertex buffer
|
||||||
ri->defaultKey = matInst->getStateHint();
|
ri->defaultKey = matInst->getStateHint();
|
||||||
ri->defaultKey2 = (uintptr_t)ri->vertBuff; // Not 64bit safe!
|
ri->defaultKey2 = (U32)ri->vertBuff; // Not 64bit safe!
|
||||||
|
|
||||||
// Submit our RenderInst to the RenderPassManager
|
// Submit our RenderInst to the RenderPassManager
|
||||||
state->getRenderPass()->addInst(ri);
|
state->getRenderPass()->addInst(ri);
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ bool GuiInspectorEntityGroup::inspectGroup()
|
||||||
{
|
{
|
||||||
Entity* target = dynamic_cast<Entity*>(mParent->getInspectObject(0));
|
Entity* target = dynamic_cast<Entity*>(mParent->getInspectObject(0));
|
||||||
|
|
||||||
Con::executef(this, "inspectObject", target->getIdString());
|
if(target)
|
||||||
|
Con::executef(this, "inspectObject", target->getIdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue