diff --git a/client/utils.cpp b/client/utils.cpp index 4e48d3da..148fe5b1 100644 --- a/client/utils.cpp +++ b/client/utils.cpp @@ -256,7 +256,7 @@ void Physic_SweepTest(cl_entity_t *pTouch, const Vector &start, const Vector &mi scale = Vector(pev->scale); } - trm.SetTraceMesh(pMesh, pHeadNode, pTouch->curstate.modelindex); + trm.SetTraceMesh(pMesh, pHeadNode, pTouch->curstate.modelindex, bodyMesh.GetBody(), bodyMesh.GetSkin()); trm.SetMeshOrientation(pev->origin, pev->angles, scale); trm.SetupTrace(start, mins, maxs, end, tr); diff --git a/game_shared/meshdesc.h b/game_shared/meshdesc.h index fdf1850d..a6768dca 100644 --- a/game_shared/meshdesc.h +++ b/game_shared/meshdesc.h @@ -66,6 +66,8 @@ class CMeshDesc // get cached collision mmesh_t *GetMesh() { return (m_bMeshBuilt) ? &m_mesh : NULL; } areanode_t *GetHeadNode() { return (has_tree) ? areanodes : NULL; } + int32_t GetBody() const { return m_iBodyNumber; } + int32_t GetSkin() const { return m_iSkinNumber; } void SetDebugName(const char *name) { m_debugName = name; } void SetModel(const model_t *mod, int32_t body, int32_t skin); diff --git a/game_shared/trace.cpp b/game_shared/trace.cpp index 1cbbc5e6..83f47f18 100644 --- a/game_shared/trace.cpp +++ b/game_shared/trace.cpp @@ -40,11 +40,13 @@ extern globalvars_t *gpGlobals; // and to avoid various numeric issues #define SURFACE_CLIP_EPSILON (0.125) -void TraceMesh :: SetTraceMesh( mmesh_t *cached_mesh, areanode_t *tree, int modelindex ) +void TraceMesh :: SetTraceMesh( mmesh_t *cached_mesh, areanode_t *tree, int modelindex, int32_t body, int32_t skin ) { m_pModel = (model_t *)MODEL_HANDLE( modelindex ); mesh = cached_mesh; areanodes = tree; + m_bodyNumber = body; + m_skinNumber = skin; } matdesc_t *TraceMesh :: GetMaterialForFacet( const mfacet_t *facet ) @@ -75,8 +77,8 @@ mstudiotexture_t *TraceMesh :: GetTextureForFacet( const mfacet_t *facet ) if (phdr->numtextures != 0 && phdr->textureindex != 0) { short *pskinref = (short *)((byte *)phdr + phdr->skinindex); - if (m_iSkin > 0 && m_iSkin < phdr->numskinfamilies) - pskinref += (m_iSkin * phdr->numskinref); + if (m_skinNumber > 0 && m_skinNumber < phdr->numskinfamilies) + pskinref += (m_skinNumber * phdr->numskinref); return &textures[pskinref[facet->skinref]]; } diff --git a/game_shared/trace.h b/game_shared/trace.h index 3ef41995..397bb67d 100644 --- a/game_shared/trace.h +++ b/game_shared/trace.h @@ -49,8 +49,8 @@ class TraceMesh Vector m_vecOrigin; Vector m_vecAngles; Vector m_vecScale; - int m_iSkin; - int m_iBody; + int32_t m_bodyNumber; + int32_t m_skinNumber; matrix4x4 m_transform; model_t *m_pModel; @@ -59,17 +59,10 @@ class TraceMesh ~TraceMesh() {} // trace stuff - void SetTraceMesh( mmesh_t *cached_mesh, areanode_t *tree, int modelindex ); + void SetTraceMesh( mmesh_t *cached_mesh, areanode_t *tree, int modelindex, int32_t body, int32_t skin ); void SetMeshOrientation( const Vector &pos, const Vector &ang, const Vector &xform ) { m_vecOrigin = pos, m_vecAngles = ang, m_vecScale = xform; - m_iBody = m_iSkin = 0; // reset it - } - - void SetMeshParams( int body, int skin ) - { - m_iBody = body; - m_iSkin = skin; } void SetupTrace( const Vector &start, const Vector &mins, const Vector &maxs, const Vector &end, trace_t *trace ); diff --git a/server/physx/physx_impl.cpp b/server/physx/physx_impl.cpp index a5a549cb..fe84ab8b 100644 --- a/server/physx/physx_impl.cpp +++ b/server/physx/physx_impl.cpp @@ -2616,6 +2616,8 @@ void CPhysicPhysX :: SweepTest( CBaseEntity *pTouch, const Vector &start, const mmesh_t *pMesh; areanode_t *pHeadNode; + int32_t meshBody, meshSkin; + if (mod->type == mod_studio && FBitSet(gpGlobals->trace_flags, FTRACE_MATERIAL_TRACE)) { CMeshDesc &originalMesh = meshDescFactory.CreateObject(pTouch->pev->modelindex, pTouch->pev->body, pTouch->pev->skin, clipfile::GeometryType::Original); @@ -2627,17 +2629,21 @@ void CPhysicPhysX :: SweepTest( CBaseEntity *pTouch, const Vector &start, const } } + meshBody = originalMesh.GetBody(); + meshSkin = originalMesh.GetSkin(); pMesh = originalMesh.GetMesh(); pHeadNode = originalMesh.GetHeadNode(); } else { + meshBody = cookedMesh.GetBody(); + meshSkin = cookedMesh.GetSkin(); pMesh = cookedMesh.GetMesh(); pHeadNode = cookedMesh.GetHeadNode(); } TraceMesh trm; - trm.SetTraceMesh(pMesh, pHeadNode, pTouch->pev->modelindex); + trm.SetTraceMesh(pMesh, pHeadNode, pTouch->pev->modelindex, meshBody, meshSkin); trm.SetMeshOrientation(pTouch->pev->origin, pTouch->pev->angles, pTouch->GetScale()); trm.SetupTrace(start, mins, maxs, end, tr);