Ver código fonte

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.

Areloch 9 anos atrás
pai
commit
2464b620ba

+ 4 - 2
Engine/source/T3D/components/animation/animationComponent.cpp

@@ -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++)

+ 26 - 0
Engine/source/T3D/components/camera/cameraOrbiterComponent.cpp

@@ -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);

+ 3 - 0
Engine/source/T3D/components/camera/cameraOrbiterComponent.h

@@ -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);
 

+ 3 - 1
Engine/source/T3D/components/physics/playerControllerComponent.cpp

@@ -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

+ 1 - 0
Engine/source/T3D/components/render/meshComponent.cpp

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

+ 9 - 5
Engine/source/T3D/entity.cpp

@@ -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

+ 0 - 1
Templates/Full/game/scripts/server/gameObjects/ThirdPersonPlayerObject.taml

@@ -1,6 +1,5 @@
 <Entity
     scale="1 1 1"
-    isSelectionEnabled="false"
     class="ThirdPersonPlayerObject"
     canSave="true"
     canSaveDynamicFields="true"