2
0
Эх сурвалжийг харах

skip transmitting server authorative wheel spin
it's not in itself a force-injection, so we can just use the existing calcs (also. fix the exisitng calcs so slippling is properly cleared)
in addition, rigidshaeps shouldn't be trying to resolve collisions with things mounted to them any more than they should self-collide. it's a hard-locked relational association

AzaezelX 3 долоо хоног өмнө
parent
commit
5ea10f1cfc

+ 7 - 1
Engine/source/T3D/rigidShape.cpp

@@ -1253,6 +1253,9 @@ bool RigidShape::updateCollision(F32 dt)
    mRigid.getTransform(&mat);
    mRigid.getTransform(&mat);
    cmat = mConvex.getTransform();
    cmat = mConvex.getTransform();
 
 
+   SceneObject* mounted;
+   for (mounted = getMountList(); mounted; mounted = mounted->getMountLink())
+      mounted->disableCollision();
    mCollisionList.clear();
    mCollisionList.clear();
    CollisionState *state = mConvex.findClosestState(cmat, getScale(), mDataBlock->collisionTol);
    CollisionState *state = mConvex.findClosestState(cmat, getScale(), mDataBlock->collisionTol);
    if (state && state->mDist <= mDataBlock->collisionTol) 
    if (state && state->mDist <= mDataBlock->collisionTol) 
@@ -1260,9 +1263,12 @@ bool RigidShape::updateCollision(F32 dt)
       //resolveDisplacement(ns,state,dt);
       //resolveDisplacement(ns,state,dt);
       mConvex.getCollisionInfo(cmat, getScale(), &mCollisionList, mDataBlock->collisionTol);
       mConvex.getCollisionInfo(cmat, getScale(), &mCollisionList, mDataBlock->collisionTol);
    }
    }
-
    // Resolve collisions
    // Resolve collisions
    bool collided = resolveCollision(mRigid,mCollisionList, dt);
    bool collided = resolveCollision(mRigid,mCollisionList, dt);
+
+   for (mounted = getMountList(); mounted; mounted = mounted->getMountLink())
+      mounted->enableCollision();
+
    return collided;
    return collided;
 }
 }
 
 

+ 17 - 15
Engine/source/T3D/vehicles/wheeledVehicle.cpp

@@ -821,7 +821,7 @@ void WheeledVehicle::advanceTime(F32 dt)
 
 
    // Stick the wheels to the ground.  This is purely so they look
    // Stick the wheels to the ground.  This is purely so they look
    // good while the vehicle is being interpolated.
    // good while the vehicle is being interpolated.
-   //extendWheels();
+   extendWheels(isClientObject());
 
 
    // Update wheel angular position and slip, this is a client visual
    // Update wheel angular position and slip, this is a client visual
    // feature only, it has no affect on the physics.
    // feature only, it has no affect on the physics.
@@ -1201,6 +1201,7 @@ void WheeledVehicle::extendWheels(bool clientHack)
             wheel->surface.pos      = rInfo.point;
             wheel->surface.pos      = rInfo.point;
             wheel->surface.material = rInfo.material;
             wheel->surface.material = rInfo.material;
             wheel->surface.object   = rInfo.object;
             wheel->surface.object   = rInfo.object;
+            wheel->slipping = false;
          }
          }
          else 
          else 
          {
          {
@@ -1475,35 +1476,36 @@ void WheeledVehicle::writePacketData(GameConnection *connection, BitStream *stre
 {
 {
    Parent::writePacketData(connection, stream);
    Parent::writePacketData(connection, stream);
    stream->writeFlag(mBraking);
    stream->writeFlag(mBraking);
-
-   Wheel* wend = &mWheel[mDataBlock->wheelCount];
-   for (Wheel* wheel = mWheel; wheel < wend; wheel++) 
-   {
-      stream->write(wheel->avel);
-      stream->write(wheel->Dy);
-      stream->write(wheel->Dx);
-      stream->writeFlag(wheel->slipping);
-   }
+   
 }
 }
 
 
 void WheeledVehicle::readPacketData(GameConnection *connection, BitStream *stream)
 void WheeledVehicle::readPacketData(GameConnection *connection, BitStream *stream)
 {
 {
    Parent::readPacketData(connection, stream);
    Parent::readPacketData(connection, stream);
    mBraking = stream->readFlag();
    mBraking = stream->readFlag();
-
+   
    Wheel* wend = &mWheel[mDataBlock->wheelCount];
    Wheel* wend = &mWheel[mDataBlock->wheelCount];
+
    for (Wheel* wheel = mWheel; wheel < wend; wheel++) 
    for (Wheel* wheel = mWheel; wheel < wend; wheel++) 
    {
    {
-      stream->read(&wheel->avel);
-      stream->read(&wheel->Dy);
-      stream->read(&wheel->Dx);
-      wheel->slipping = stream->readFlag();
+      if (wheel->tire && wheel->spring) {
+         // Update angular position
+         wheel->apos += (wheel->avel) / M_2PI;
+         wheel->apos -= mFloor(wheel->apos);
+         if (wheel->apos < 0)
+            wheel->apos = 1 - wheel->apos;
+      }
    }
    }
 
 
    // Rigid state is transmitted by the parent...
    // Rigid state is transmitted by the parent...
    setPosition(mRigid.linPosition,mRigid.angPosition);
    setPosition(mRigid.linPosition,mRigid.angPosition);
    mDelta.pos = mRigid.linPosition;
    mDelta.pos = mRigid.linPosition;
    mDelta.rot[1] = mRigid.angPosition;
    mDelta.rot[1] = mRigid.angPosition;
+
+   // Stick the wheels to the ground.  This is purely so they look
+   // good while the vehicle is being interpolated.
+   extendWheels(isClientObject());
+   updateWheelThreads();
 }
 }