Some code cleanup, tweak and optimizations for assets, entities and components.

This commit is contained in:
Areloch 2018-02-04 16:21:07 -06:00
parent cfbdf63cd7
commit abe4370c8a
15 changed files with 58 additions and 40 deletions

View file

@ -90,14 +90,9 @@ ConsoleSetType(TypeImageAssetPtr)
//-----------------------------------------------------------------------------
ImageAsset::ImageAsset()
ImageAsset::ImageAsset() : AssetBase(), mImage(nullptr), mUseMips(true), mIsHDRImage(false), mIsValidImage(false)
{
mImageFileName = StringTable->EmptyString();
mImage = NULL;
mUseMips = true;
mIsHDRImage = false;
mIsValidImage = false;
}
//-----------------------------------------------------------------------------

View file

@ -47,11 +47,6 @@ class ImageAsset : public AssetBase
{
typedef AssetBase Parent;
AssetManager* mpOwningAssetManager;
bool mAssetInitialized;
AssetDefinition* mpAssetDefinition;
U32 mAcquireReferenceCount;
StringTableEntry mImageFileName;
GFXTexHandle mImage;

View file

@ -90,10 +90,12 @@ ConsoleSetType(TypeLevelAssetPtr)
//-----------------------------------------------------------------------------
LevelAsset::LevelAsset()
LevelAsset::LevelAsset() : AssetBase(), mIsSubLevel(false)
{
mLevelFile = StringTable->EmptyString();
mPreviewImage = StringTable->EmptyString();
mMainLevelAsset = StringTable->EmptyString();
}
//-----------------------------------------------------------------------------

View file

@ -89,7 +89,7 @@ ConsoleSetType(TypeScriptAssetPtr)
//-----------------------------------------------------------------------------
ScriptAsset::ScriptAsset()
ScriptAsset::ScriptAsset() : AssetBase(), mIsServerSide(true)
{
mScriptFilePath = StringTable->EmptyString();
}

View file

@ -613,6 +613,9 @@ void AnimationComponent::advanceThreads(F32 dt)
if (!mOwnerRenderInst)
return;
if (mOwnerShapeInstance == nullptr || !getShape())
return;
for (U32 i = 0; i < MaxScriptThreads; i++)
{
Thread& st = mAnimationThreads[i];

View file

@ -142,10 +142,12 @@ CollisionComponent::CollisionComponent() : Component()
StaticShapeObjectType | VehicleObjectType |
VehicleBlockerObjectType | DynamicShapeObjectType | StaticObjectType | EntityObjectType | TriggerObjectType);
mPhysicsRep = NULL;
mPhysicsWorld = NULL;
mPhysicsRep = nullptr;
mPhysicsWorld = nullptr;
mTimeoutList = NULL;
mTimeoutList = nullptr;
mAnimated = false;
}
CollisionComponent::~CollisionComponent()

View file

@ -67,6 +67,13 @@ Component::Component()
mOriginatingAssetId = StringTable->EmptyString();
mIsServerObject = true;
componentIdx = 0;
mHidden = false;
mEnabled = true;
mDirtyMaskBits = 0;
}
Component::~Component()
@ -535,7 +542,7 @@ const char * Component::getDescriptionText(const char *desc)
if (desc == NULL)
return NULL;
char *newDesc;
char *newDesc = "";
// [tom, 1/12/2007] If it isn't a file, just do it the easy way
if (!Platform::isFile(desc))
@ -568,7 +575,7 @@ const char * Component::getDescriptionText(const char *desc)
}
str.close();
delete stream;
//delete stream;
return newDesc;
}

View file

@ -30,6 +30,10 @@ StateMachine::StateMachine()
mStartingState = "";
mCurCreateState = NULL;
mStateMachineFile = StringTable->EmptyString();
mCurCreateState = nullptr;
}
StateMachine::~StateMachine()

View file

@ -158,6 +158,8 @@ public:
{
if (index <= mFields.size())
return mFields[index];
return StateField(); //return a blank one
}
Signal< void(StateMachine*, S32 stateIdx) > onStateChanged;

View file

@ -119,8 +119,11 @@ PlayerControllerComponent::PlayerControllerComponent() : Component()
mInputVelocity = Point3F(0, 0, 0);
mPhysicsRep = NULL;
mPhysicsWorld = NULL;
mPhysicsRep = nullptr;
mPhysicsWorld = nullptr;
mOwnerCollisionInterface = nullptr;
mIntegrationCount = 0;
}
PlayerControllerComponent::~PlayerControllerComponent()

View file

@ -59,7 +59,7 @@ ImplementEnumType(BatchingMode,
//////////////////////////////////////////////////////////////////////////
// Constructor/Destructor
//////////////////////////////////////////////////////////////////////////
MeshComponent::MeshComponent() : Component()
MeshComponent::MeshComponent() : Component(), mShape(nullptr), mRenderMode(Individual)
{
mFriendlyName = "Mesh Component";
mComponentType = "Render";

View file

@ -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();
@ -922,7 +922,7 @@ void Entity::setRenderTransform(const MatrixF &mat)
Parent::setRenderTransform(mat);
}
void Entity::setRenderTransform(Point3F position, RotationF rotation)
void Entity::setRenderTransform(const Point3F& position, const RotationF& rotation)
{
if (isMounted())
{
@ -977,7 +977,7 @@ MatrixF Entity::getTransform()
}
}
void Entity::setMountOffset(Point3F posOffset)
void Entity::setMountOffset(const Point3F& posOffset)
{
if (isMounted())
{
@ -987,7 +987,7 @@ void Entity::setMountOffset(Point3F posOffset)
}
}
void Entity::setMountRotation(EulerF rotOffset)
void Entity::setMountRotation(const EulerF& rotOffset)
{
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)
{
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++)
{
return (*it)->buildPolyList(context, polyList, box, sphere);
}
}*/
return false;
}
@ -1131,7 +1132,7 @@ void Entity::buildConvex(const Box3F& box, Convex* convex)
//
// 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::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;
resetWorldBox();
@ -1705,8 +1706,8 @@ void Entity::setComponentDirty(Component *comp, bool forceUpdate)
}
}
if (!found)
return;
//if (!found)
// return;
//if(mToLoadComponents.empty())
// mStartComponentUpdate = true;

View file

@ -152,14 +152,14 @@ public:
virtual void setTransform(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 Point3F getPosition() const { return mPos; }
void setRotation(RotationF rotation) {
void setRotation(const RotationF& rotation) {
mRot = rotation;
setMaskBits(TransformMask);
};
@ -167,8 +167,8 @@ public:
static bool _setGameObject(void *object, const char *index, const char *data);
void setMountOffset(Point3F posOffset);
void setMountRotation(EulerF rotOffset);
void setMountOffset(const Point3F& posOffset);
void setMountRotation(const EulerF& rotOffset);
//static bool _setEulerRotation( 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 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 onUnmount(SceneObject *obj, S32 node);
@ -218,7 +218,7 @@ public:
return mComponents.size();
}
virtual void setObjectBox(Box3F objBox);
virtual void setObjectBox(const Box3F& objBox);
void resetWorldBox() { Parent::resetWorldBox(); }
void resetObjectBox() { Parent::resetObjectBox(); }

View file

@ -11,6 +11,9 @@ Vector<MeshRenderSystem::BufferSet> MeshRenderSystem::mStaticBuffers(0);
void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* state)
{
if (sceneManager == nullptr || state == nullptr)
return;
Frustum viewFrustum = state->getCullingFrustum();
MatrixF camTransform = state->getCameraTransform();
@ -129,7 +132,7 @@ void MeshRenderSystem::render(SceneManager *sceneManager, SceneRenderState* stat
// We sort by the material then vertex buffer
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
state->getRenderPass()->addInst(ri);

View file

@ -70,7 +70,8 @@ bool GuiInspectorEntityGroup::inspectGroup()
{
Entity* target = dynamic_cast<Entity*>(mParent->getInspectObject(0));
Con::executef(this, "inspectObject", target->getIdString());
if(target)
Con::executef(this, "inspectObject", target->getIdString());
}
return true;