mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Merge pull request #220 from DavidWyand-GG/RigidShapeChanges
New RigidShape method to force client
This commit is contained in:
commit
404cffc11a
2 changed files with 30 additions and 5 deletions
|
|
@ -1003,6 +1003,11 @@ void RigidShape::setTransform(const MatrixF& newMat)
|
||||||
mContacts.clear();
|
mContacts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RigidShape::forceClientTransform()
|
||||||
|
{
|
||||||
|
setMaskBits(ForceMoveMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -1456,6 +1461,8 @@ U32 RigidShape::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||||
|
|
||||||
if (stream->writeFlag(mask & PositionMask))
|
if (stream->writeFlag(mask & PositionMask))
|
||||||
{
|
{
|
||||||
|
stream->writeFlag(mask & ForceMoveMask);
|
||||||
|
|
||||||
stream->writeCompressedPoint(mRigid.linPosition);
|
stream->writeCompressedPoint(mRigid.linPosition);
|
||||||
mathWrite(*stream, mRigid.angPosition);
|
mathWrite(*stream, mRigid.angPosition);
|
||||||
mathWrite(*stream, mRigid.linMomentum);
|
mathWrite(*stream, mRigid.linMomentum);
|
||||||
|
|
@ -1480,6 +1487,10 @@ void RigidShape::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
|
|
||||||
if (stream->readFlag())
|
if (stream->readFlag())
|
||||||
{
|
{
|
||||||
|
// Check if we need to jump to the given transform
|
||||||
|
// rather than interpolate to it.
|
||||||
|
bool forceUpdate = stream->readFlag();
|
||||||
|
|
||||||
mPredictionCount = sMaxPredictionTicks;
|
mPredictionCount = sMaxPredictionTicks;
|
||||||
F32 speed = mRigid.linVelocity.len();
|
F32 speed = mRigid.linVelocity.len();
|
||||||
mDelta.warpRot[0] = mRigid.angPosition;
|
mDelta.warpRot[0] = mRigid.angPosition;
|
||||||
|
|
@ -1492,7 +1503,7 @@ void RigidShape::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
mRigid.atRest = stream->readFlag();
|
mRigid.atRest = stream->readFlag();
|
||||||
mRigid.updateVelocity();
|
mRigid.updateVelocity();
|
||||||
|
|
||||||
if (isProperlyAdded())
|
if (!forceUpdate && isProperlyAdded())
|
||||||
{
|
{
|
||||||
// Determine number of ticks to warp based on the average
|
// Determine number of ticks to warp based on the average
|
||||||
// of the client and server velocities.
|
// of the client and server velocities.
|
||||||
|
|
@ -1710,3 +1721,12 @@ DefineEngineMethod( RigidShape, freezeSim, void, (bool isFrozen),,
|
||||||
{
|
{
|
||||||
object->freezeSim(isFrozen);
|
object->freezeSim(isFrozen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod( RigidShape, forceClientTransform, void, (),,
|
||||||
|
"@brief Forces the client to jump to the RigidShape's transform rather then warp to it.\n\n")
|
||||||
|
{
|
||||||
|
if(object->isServerObject())
|
||||||
|
{
|
||||||
|
object->forceClientTransform();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,10 +152,11 @@ class RigidShape: public ShapeBase
|
||||||
WheelCollision = BIT(1),
|
WheelCollision = BIT(1),
|
||||||
};
|
};
|
||||||
enum MaskBits {
|
enum MaskBits {
|
||||||
PositionMask = Parent::NextFreeMask << 0,
|
PositionMask = Parent::NextFreeMask << 0,
|
||||||
EnergyMask = Parent::NextFreeMask << 1,
|
EnergyMask = Parent::NextFreeMask << 1,
|
||||||
FreezeMask = Parent::NextFreeMask << 2,
|
FreezeMask = Parent::NextFreeMask << 2,
|
||||||
NextFreeMask = Parent::NextFreeMask << 3
|
ForceMoveMask = Parent::NextFreeMask << 3,
|
||||||
|
NextFreeMask = Parent::NextFreeMask << 4
|
||||||
};
|
};
|
||||||
|
|
||||||
void updateDustTrail( F32 dt );
|
void updateDustTrail( F32 dt );
|
||||||
|
|
@ -283,6 +284,10 @@ public:
|
||||||
/// @param impulse Impulse vector to apply.
|
/// @param impulse Impulse vector to apply.
|
||||||
void applyImpulse(const Point3F &r, const Point3F &impulse);
|
void applyImpulse(const Point3F &r, const Point3F &impulse);
|
||||||
|
|
||||||
|
/// Forces the client to jump to the RigidShape's transform rather
|
||||||
|
/// then warp to it.
|
||||||
|
void forceClientTransform();
|
||||||
|
|
||||||
void getCameraParameters(F32 *min, F32* max, Point3F* offset, MatrixF* rot);
|
void getCameraParameters(F32 *min, F32* max, Point3F* offset, MatrixF* rot);
|
||||||
void getCameraTransform(F32* pos, MatrixF* mat);
|
void getCameraTransform(F32* pos, MatrixF* mat);
|
||||||
///@}
|
///@}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue