Fixes several minor initialization issues that were causing problems with deletion/management of components and entities.

Also makes the ThirdPersonPlayer game object editor selectable again by removing an erroneously set field.
This commit is contained in:
Areloch 2016-05-31 12:51:23 -05:00
parent bbf7865a77
commit 2464b620ba
7 changed files with 46 additions and 9 deletions

View file

@ -149,6 +149,8 @@ bool AnimationComponent::onAdd()
void AnimationComponent::onRemove()
{
Parent::onRemove();
mOwnerRenderInst = NULL;
}
void AnimationComponent::onComponentAdd()
@ -387,7 +389,7 @@ S32 AnimationComponent::getThreadSequenceID(S32 slot)
void AnimationComponent::updateThread(Thread& st)
{
if (!mOwnerShapeInstance)
if (!mOwnerRenderInst)
return;
switch (st.state)
@ -628,7 +630,7 @@ void AnimationComponent::startSequenceSound(Thread& thread)
void AnimationComponent::advanceThreads(F32 dt)
{
if (!mOwnerShapeInstance)
if (!mOwnerRenderInst)
return;
for (U32 i = 0; i < MaxScriptThreads; i++)

View file

@ -92,6 +92,32 @@ void CameraOrbiterComponent::onComponentRemove()
Parent::onComponentRemove();
}
void CameraOrbiterComponent::componentAddedToOwner(Component *comp)
{
if (comp->getId() == getId())
return;
//test if this is a shape component!
CameraComponent *camComponent = dynamic_cast<CameraComponent*>(comp);
if (camComponent)
{
mCamera = camComponent;
}
}
void CameraOrbiterComponent::componentRemovedFromOwner(Component *comp)
{
if (comp->getId() == getId()) //?????????
return;
//test if this is a shape component!
CameraComponent *camComponent = dynamic_cast<CameraComponent*>(comp);
if (camComponent)
{
mCamera = NULL;
}
}
U32 CameraOrbiterComponent::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
{
U32 retMask = Parent::packUpdate(con, mask, stream);

View file

@ -62,6 +62,9 @@ public:
virtual void onComponentAdd();
virtual void onComponentRemove();
virtual void componentAddedToOwner(Component *comp);
virtual void componentRemovedFromOwner(Component *comp);
virtual U32 packUpdate(NetConnection *con, U32 mask, BitStream *stream);
virtual void unpackUpdate(NetConnection *con, BitStream *stream);

View file

@ -69,6 +69,8 @@ PlayerControllerComponent::PlayerControllerComponent() : Component()
mFriction = 0.3f;
mElasticity = 0.4f;
mMaxVelocity = 3000.f;
mVelocity = VectorF::Zero;
mContactTimer = 0;
mSticky = false;
mFalling = false;
@ -88,7 +90,7 @@ PlayerControllerComponent::PlayerControllerComponent() : Component()
mDescription = getDescriptionText("A general-purpose physics player controller.");
mNetFlags.set(Ghostable | ScopeAlways);
//mNetFlags.set(Ghostable | ScopeAlways);
mMass = 9.0f; // from ShapeBase
mDrag = 1.0f; // from ShapeBase

View file

@ -53,6 +53,7 @@ MeshComponent::MeshComponent() : Component()
{
mShapeName = StringTable->insert("");
mShapeAsset = StringTable->insert("");
mShapeInstance = NULL;
mChangingMaterials.clear();