mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
Merge pull request #1370 from Azaezel/alpha41/tsStaticTrouble
add lod selection for visiblemesh collisions
This commit is contained in:
commit
4bd43265a9
|
|
@ -137,6 +137,7 @@ TSStatic::TSStatic()
|
|||
mAlphaFade = 1.0f;
|
||||
mPhysicsRep = NULL;
|
||||
|
||||
mCollisionLOD = 0;
|
||||
mCollisionType = CollisionMesh;
|
||||
mDecalType = CollisionMesh;
|
||||
|
||||
|
|
@ -238,7 +239,8 @@ void TSStatic::initPersistFields()
|
|||
endGroup("Reflection");
|
||||
|
||||
addGroup("Collision");
|
||||
|
||||
addField("collisionLOD", TypeS32, Offset(mCollisionLOD, TSStatic),
|
||||
"The level of detail to use for 'Visible Mesh' collision queries.");
|
||||
addField("collisionType", TypeTSMeshType, Offset(mCollisionType, TSStatic),
|
||||
"The type of mesh data to use for collision queries.");
|
||||
addField("decalType", TypeTSMeshType, Offset(mDecalType, TSStatic),
|
||||
|
|
@ -531,20 +533,20 @@ void TSStatic::prepCollision()
|
|||
|
||||
if (mCollisionType == CollisionMesh || mCollisionType == VisibleMesh)
|
||||
{
|
||||
mShape->findColDetails(mCollisionType == VisibleMesh, &mCollisionDetails, &mLOSDetails);
|
||||
mShape->findColDetails(mCollisionType == VisibleMesh, &mCollisionDetails, &mLOSDetails, mCollisionLOD);
|
||||
if (mDecalType == mCollisionType)
|
||||
{
|
||||
mDecalDetailsPtr = &mCollisionDetails;
|
||||
}
|
||||
else if (mDecalType == CollisionMesh || mDecalType == VisibleMesh)
|
||||
{
|
||||
mShape->findColDetails(mDecalType == VisibleMesh, &mDecalDetails, 0);
|
||||
mShape->findColDetails(mDecalType == VisibleMesh, &mDecalDetails, 0, mCollisionLOD);
|
||||
mDecalDetailsPtr = &mDecalDetails;
|
||||
}
|
||||
}
|
||||
else if (mDecalType == CollisionMesh || mDecalType == VisibleMesh)
|
||||
{
|
||||
mShape->findColDetails(mDecalType == VisibleMesh, &mDecalDetails, 0);
|
||||
mShape->findColDetails(mDecalType == VisibleMesh, &mDecalDetails, 0, mCollisionLOD);
|
||||
mDecalDetailsPtr = &mDecalDetails;
|
||||
}
|
||||
|
||||
|
|
@ -947,8 +949,10 @@ U32 TSStatic::packUpdate(NetConnection* con, U32 mask, BitStream* stream)
|
|||
}
|
||||
|
||||
if (stream->writeFlag(mask & UpdateCollisionMask))
|
||||
{
|
||||
stream->write(mCollisionLOD);
|
||||
stream->write((U32)mCollisionType);
|
||||
|
||||
}
|
||||
if (stream->writeFlag(mask & SkinMask))
|
||||
con->packNetStringHandleU(stream, mSkinNameHandle);
|
||||
|
||||
|
|
@ -1045,6 +1049,7 @@ void TSStatic::unpackUpdate(NetConnection* con, BitStream* stream)
|
|||
{
|
||||
U32 collisionType = CollisionMesh;
|
||||
|
||||
stream->read(&mCollisionLOD);
|
||||
stream->read(&collisionType);
|
||||
|
||||
// Handle it if we have changed CollisionType's
|
||||
|
|
@ -1255,7 +1260,7 @@ bool TSStatic::buildPolyList(PolyListContext context, AbstractPolyList* polyList
|
|||
else if (meshType == Bounds)
|
||||
polyList->addBox(mObjBox);
|
||||
else if (meshType == VisibleMesh)
|
||||
mShapeInstance->buildPolyList(polyList, 0);
|
||||
mShapeInstance->buildPolyListOpcode(0, polyList, box);
|
||||
else if (context == PLC_Decal && mDecalDetailsPtr != 0)
|
||||
{
|
||||
for (U32 i = 0; i < mDecalDetailsPtr->size(); i++)
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ protected:
|
|||
TSThread* mAmbientThread;
|
||||
F32 mAnimOffset;
|
||||
F32 mAnimSpeed;
|
||||
S16 mCollisionLOD;
|
||||
/// The type of mesh data to return for collision queries.
|
||||
MeshType mCollisionType;
|
||||
|
||||
|
|
|
|||
|
|
@ -811,11 +811,11 @@ bool TSShapeInstance::buildConvexOpcode( const MatrixF &objMat, const Point3F &o
|
|||
return emitted;
|
||||
}
|
||||
|
||||
void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vector<S32> *outLOSDetails ) const
|
||||
void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vector<S32> *outLOSDetails, S32 specifiedLOD) const
|
||||
{
|
||||
PROFILE_SCOPE( TSShape_findColDetails );
|
||||
|
||||
if ( useVisibleMesh )
|
||||
if ( useVisibleMesh || (specifiedLOD !=0))
|
||||
{
|
||||
// If we're using the visible mesh for collision then
|
||||
// find the highest detail and use that.
|
||||
|
|
@ -836,12 +836,23 @@ void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vect
|
|||
dStrStartsWith( name, "LOS" ) )
|
||||
continue;
|
||||
*/
|
||||
|
||||
// Otherwise test against the current highest size
|
||||
if ( details[i].size > highestSize )
|
||||
if (specifiedLOD != 0)
|
||||
{
|
||||
highestDetail = i;
|
||||
highestSize = details[i].size;
|
||||
if (details[i].size == specifiedLOD)
|
||||
{
|
||||
highestDetail = i;
|
||||
highestSize = details[i].size;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise test against the current highest size
|
||||
if (details[i].size > highestSize)
|
||||
{
|
||||
highestDetail = i;
|
||||
highestSize = details[i].size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -852,7 +863,6 @@ void TSShape::findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vect
|
|||
if ( outLOSDetails )
|
||||
outLOSDetails->push_back( highestDetail );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ class TSShape
|
|||
/// @param outDetails The output detail index vector.
|
||||
/// @param outLOSDetails The optional output LOS detail vector.
|
||||
///
|
||||
void findColDetails( bool useVisibleMesh, Vector<S32> *outDetails, Vector<S32> *outLOSDetails ) const;
|
||||
void findColDetails(bool useVisibleMesh, Vector<S32>* outDetails, Vector<S32>* outLOSDetails, S32 specifiedLOD = 0 ) const;
|
||||
|
||||
/// Builds a physics collision shape at the requested scale.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in a new issue