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