mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
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:
parent
bbf7865a77
commit
2464b620ba
|
|
@ -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++)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ MeshComponent::MeshComponent() : Component()
|
|||
{
|
||||
mShapeName = StringTable->insert("");
|
||||
mShapeAsset = StringTable->insert("");
|
||||
mShapeInstance = NULL;
|
||||
|
||||
mChangingMaterials.clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -405,8 +405,9 @@ U32 Entity::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
|||
//mathWrite( *stream, getScale() );
|
||||
//stream->writeAffineTransform(mObjToWorld);
|
||||
//mathWrite(*stream, getPosition());
|
||||
mathWrite(*stream, mPos);
|
||||
//mathWrite(*stream, mPos);
|
||||
|
||||
stream->writeCompressedPoint(mPos);
|
||||
mathWrite(*stream, getRotation());
|
||||
|
||||
mDelta.move.pack(stream);
|
||||
|
|
@ -500,7 +501,8 @@ void Entity::unpackUpdate(NetConnection *con, BitStream *stream)
|
|||
|
||||
Point3F pos;
|
||||
|
||||
mathRead(*stream, &pos);
|
||||
stream->readCompressedPoint(&pos);
|
||||
//mathRead(*stream, &pos);
|
||||
|
||||
RotationF rot;
|
||||
|
||||
|
|
@ -893,8 +895,10 @@ void Entity::setMountRotation(EulerF rotOffset)
|
|||
void Entity::getCameraTransform(F32* pos, MatrixF* mat)
|
||||
{
|
||||
Vector<CameraInterface*> updaters = getComponents<CameraInterface>();
|
||||
for (Vector<CameraInterface*>::iterator it = updaters.begin(); it != updaters.end(); it++) {
|
||||
if ((*it)->getCameraTransform(pos, mat)) {
|
||||
for (Vector<CameraInterface*>::iterator it = updaters.begin(); it != updaters.end(); it++)
|
||||
{
|
||||
if ((*it)->getCameraTransform(pos, mat))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1210,7 +1214,7 @@ void Entity::removeObject(SimObject* object)
|
|||
|
||||
bool Entity::addComponent(Component *comp)
|
||||
{
|
||||
if (comp == NULL || !comp->isProperlyAdded())
|
||||
if (comp == NULL)
|
||||
return false;
|
||||
|
||||
//double-check were not re-adding anything
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<Entity
|
||||
scale="1 1 1"
|
||||
isSelectionEnabled="false"
|
||||
class="ThirdPersonPlayerObject"
|
||||
canSave="true"
|
||||
canSaveDynamicFields="true"
|
||||
|
|
|
|||
Loading…
Reference in a new issue