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
This commit is contained in:
AzaezelX 2025-08-16 20:38:32 -05:00
parent 2af8bf25d5
commit 5ea10f1cfc
2 changed files with 24 additions and 16 deletions

View file

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

View file

@ -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
{ {
@ -1476,14 +1477,6 @@ 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)
@ -1492,18 +1485,27 @@ void WheeledVehicle::readPacketData(GameConnection *connection, BitStream *strea
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); if (wheel->tire && wheel->spring) {
stream->read(&wheel->Dy); // Update angular position
stream->read(&wheel->Dx); wheel->apos += (wheel->avel) / M_2PI;
wheel->slipping = stream->readFlag(); 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();
} }