Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1086 lines
35 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //===========================================================================//
  8. #include "istudiorender.h"
  9. #include "materialsystem/imesh.h"
  10. #include "mathlib/mathlib.h"
  11. #include "matsyswin.h"
  12. #include "viewersettings.h"
  13. #include "materialsystem/imaterialvar.h"
  14. #include "tier1/UtlSortVector.h"
  15. #include "tier2/tier2.h"
  16. #define NORMAL_LENGTH .5f
  17. #define NORMAL_OFFSET_FROM_MESH 0.1f
  18. int DebugDrawModel( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  19. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, int flags )
  20. {
  21. // Make static so that we aren't reallocating everything all the time.
  22. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  23. static GetTriangles_Output_t tris;
  24. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  25. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  26. pRenderContext->MatrixMode( MATERIAL_MODEL );
  27. pRenderContext->PushMatrix();
  28. pRenderContext->LoadIdentity();
  29. CMeshBuilder meshBuilder;
  30. int batchID;
  31. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  32. {
  33. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  34. pRenderContext->Bind( materialBatch.m_pMaterial );
  35. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  36. int indexStart;
  37. for (indexStart = 0; indexStart < materialBatch.m_TriListIndices.Count(); )
  38. {
  39. // FIXME: this shouldn't be needed, models shouldn't be built that can't fit
  40. int nClampedIndices = MIN( materialBatch.m_TriListIndices.Count(), 32766 );
  41. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, materialBatch.m_Verts.Count(), nClampedIndices );
  42. int vertID;
  43. // Send the vertices down to the hardware.
  44. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  45. {
  46. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  47. const Vector &pos = vert.m_Position;
  48. const Vector &normal = vert.m_Normal;
  49. const Vector4D &tangentS = vert.m_TangentS;
  50. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  51. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  52. Vector4D skinnedTangentS( 0.0f, 0.0f, 0.0f, vert.m_TangentS[3] );
  53. int k;
  54. for( k = 0; k < vert.m_NumBones; k++ )
  55. {
  56. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  57. Vector tmp;
  58. VectorTransform( pos, poseToWorld, tmp );
  59. skinnedPos += vert.m_BoneWeight[k] * tmp;
  60. VectorRotate( normal, poseToWorld, tmp );
  61. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  62. VectorRotate( tangentS.AsVector3D(), poseToWorld, tmp );
  63. skinnedTangentS.AsVector3D() += vert.m_BoneWeight[k] * tmp;
  64. }
  65. meshBuilder.Position3fv( &skinnedPos.x );
  66. meshBuilder.Normal3fv( &skinnedNormal.x );
  67. meshBuilder.TexCoord2fv( 0, &vert.m_TexCoord.x );
  68. meshBuilder.UserData( &skinnedTangentS.x );
  69. meshBuilder.AdvanceVertex();
  70. }
  71. int i;
  72. // Set the indices down to the hardware.
  73. // Each triplet of indices is a triangle.
  74. for( i = indexStart; i < indexStart + nClampedIndices; i++ )
  75. {
  76. meshBuilder.FastIndex( materialBatch.m_TriListIndices[i] );
  77. }
  78. meshBuilder.End();
  79. pBuildMesh->Draw();
  80. indexStart += nClampedIndices;
  81. }
  82. }
  83. pRenderContext->MatrixMode( MATERIAL_MODEL );
  84. pRenderContext->PopMatrix();
  85. return 0;
  86. }
  87. int DebugDrawModelNormals( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  88. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, int flags )
  89. {
  90. // Make static so that we aren't reallocating everything all the time.
  91. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  92. static GetTriangles_Output_t tris;
  93. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  94. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  95. pRenderContext->MatrixMode( MATERIAL_MODEL );
  96. pRenderContext->PushMatrix();
  97. pRenderContext->LoadIdentity();
  98. int batchID;
  99. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  100. {
  101. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  102. CMeshBuilder meshBuilder;
  103. pRenderContext->Bind( g_materialVertexColor );
  104. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh();
  105. int vertID;
  106. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); )
  107. {
  108. int nClamped = MIN( materialBatch.m_Verts.Count() - vertID, 32768 / 2 );
  109. meshBuilder.Begin( pBuildMesh, MATERIAL_LINES, nClamped );
  110. // Send the vertices down to the hardware.
  111. for( ; nClamped > 0; vertID++, nClamped-- )
  112. {
  113. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  114. const Vector &pos = vert.m_Position;
  115. const Vector &normal = vert.m_Normal;
  116. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  117. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  118. int k;
  119. for( k = 0; k < vert.m_NumBones; k++ )
  120. {
  121. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  122. Vector tmp;
  123. VectorTransform( pos, poseToWorld, tmp );
  124. skinnedPos += vert.m_BoneWeight[k] * tmp;
  125. VectorRotate( normal, poseToWorld, tmp );
  126. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  127. }
  128. // skinnedPos += skinnedNormal * NORMAL_OFFSET_FROM_MESH;
  129. meshBuilder.Position3fv( &skinnedPos.x );
  130. meshBuilder.Color3f( 0.0f, 0.0f, 1.0f );
  131. meshBuilder.AdvanceVertex();
  132. skinnedPos += skinnedNormal * NORMAL_LENGTH;
  133. meshBuilder.Position3fv( &skinnedPos.x );
  134. meshBuilder.Color3f( 0.0f, 0.0f, 1.0f );
  135. meshBuilder.AdvanceVertex();
  136. }
  137. meshBuilder.End();
  138. pBuildMesh->Draw();
  139. }
  140. }
  141. pRenderContext->MatrixMode( MATERIAL_MODEL );
  142. pRenderContext->PopMatrix();
  143. return 0;
  144. }
  145. int DebugDrawModelTangentS( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  146. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, int flags )
  147. {
  148. // Make static so that we aren't reallocating everything all the time.
  149. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  150. static GetTriangles_Output_t tris;
  151. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  152. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  153. pRenderContext->MatrixMode( MATERIAL_MODEL );
  154. pRenderContext->PushMatrix();
  155. pRenderContext->LoadIdentity();
  156. int batchID;
  157. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  158. {
  159. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  160. CMeshBuilder meshBuilder;
  161. pRenderContext->Bind( g_materialVertexColor );
  162. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh();
  163. meshBuilder.Begin( pBuildMesh, MATERIAL_LINES, materialBatch.m_Verts.Count() );
  164. int vertID;
  165. // Send the vertices down to the hardware.
  166. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  167. {
  168. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  169. const Vector &pos = vert.m_Position;
  170. const Vector &normal = vert.m_Normal;
  171. const Vector4D &tangentS = vert.m_TangentS;
  172. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  173. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  174. Vector4D skinnedTangentS( 0.0f, 0.0f, 0.0f, vert.m_TangentS[3] );
  175. int k;
  176. for( k = 0; k < vert.m_NumBones; k++ )
  177. {
  178. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  179. Vector tmp;
  180. VectorTransform( pos, poseToWorld, tmp );
  181. skinnedPos += vert.m_BoneWeight[k] * tmp;
  182. VectorRotate( normal, poseToWorld, tmp );
  183. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  184. VectorRotate( tangentS.AsVector3D(), poseToWorld, tmp );
  185. skinnedTangentS.AsVector3D() += vert.m_BoneWeight[k] * tmp;
  186. }
  187. // skinnedPos += skinnedNormal * NORMAL_OFFSET_FROM_MESH;
  188. meshBuilder.Position3fv( &skinnedPos.x );
  189. meshBuilder.Color3f( 1.0f, 0.0f, 0.0f );
  190. meshBuilder.AdvanceVertex();
  191. skinnedPos += skinnedTangentS.AsVector3D() * NORMAL_LENGTH;
  192. meshBuilder.Position3fv( &skinnedPos.x );
  193. meshBuilder.Color3f( 1.0f, 0.0f, 0.0f );
  194. meshBuilder.AdvanceVertex();
  195. }
  196. meshBuilder.End();
  197. pBuildMesh->Draw();
  198. }
  199. pRenderContext->MatrixMode( MATERIAL_MODEL );
  200. pRenderContext->PopMatrix();
  201. return 0;
  202. }
  203. int DebugDrawModelTangentT( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  204. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, int flags )
  205. {
  206. // Make static so that we aren't reallocating everything all the time.
  207. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  208. static GetTriangles_Output_t tris;
  209. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  210. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  211. pRenderContext->MatrixMode( MATERIAL_MODEL );
  212. pRenderContext->PushMatrix();
  213. pRenderContext->LoadIdentity();
  214. int batchID;
  215. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  216. {
  217. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  218. CMeshBuilder meshBuilder;
  219. pRenderContext->Bind( g_materialVertexColor );
  220. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh();
  221. meshBuilder.Begin( pBuildMesh, MATERIAL_LINES, materialBatch.m_Verts.Count() );
  222. int vertID;
  223. // Send the vertices down to the hardware.
  224. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  225. {
  226. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  227. const Vector &pos = vert.m_Position;
  228. const Vector &normal = vert.m_Normal;
  229. const Vector4D &tangentS = vert.m_TangentS;
  230. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  231. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  232. Vector4D skinnedTangentS( 0.0f, 0.0f, 0.0f, vert.m_TangentS[3] );
  233. int k;
  234. for( k = 0; k < vert.m_NumBones; k++ )
  235. {
  236. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  237. Vector tmp;
  238. VectorTransform( pos, poseToWorld, tmp );
  239. skinnedPos += vert.m_BoneWeight[k] * tmp;
  240. VectorRotate( normal, poseToWorld, tmp );
  241. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  242. VectorRotate( tangentS.AsVector3D(), poseToWorld, tmp );
  243. skinnedTangentS.AsVector3D() += vert.m_BoneWeight[k] * tmp;
  244. }
  245. Vector skinnedTangentT = CrossProduct( skinnedNormal, skinnedTangentS.AsVector3D() ) * skinnedTangentS.w;
  246. // skinnedPos += skinnedNormal * NORMAL_OFFSET_FROM_MESH;
  247. meshBuilder.Position3fv( &skinnedPos.x );
  248. meshBuilder.Color3f( 0.0f, 1.0f, 0.0f );
  249. meshBuilder.AdvanceVertex();
  250. skinnedPos += skinnedTangentT * NORMAL_LENGTH;
  251. meshBuilder.Position3fv( &skinnedPos.x );
  252. meshBuilder.Color3f( 0.0f, 1.0f, 0.0f );
  253. meshBuilder.AdvanceVertex();
  254. }
  255. meshBuilder.End();
  256. pBuildMesh->Draw();
  257. }
  258. pRenderContext->MatrixMode( MATERIAL_MODEL );
  259. pRenderContext->PopMatrix();
  260. return 0;
  261. }
  262. int DebugDrawModelBadVerts( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  263. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, int flags )
  264. {
  265. // Make static so that we aren't reallocating everything all the time.
  266. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  267. static GetTriangles_Output_t tris;
  268. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  269. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  270. pRenderContext->MatrixMode( MATERIAL_MODEL );
  271. pRenderContext->PushMatrix();
  272. pRenderContext->LoadIdentity();
  273. CMeshBuilder meshBuilder;
  274. int batchID;
  275. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  276. {
  277. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  278. pRenderContext->Bind( g_materialVertexColor );
  279. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  280. int indexStart;
  281. for (indexStart = 0; indexStart < materialBatch.m_TriListIndices.Count(); )
  282. {
  283. // FIXME: this shouldn't be needed, models shouldn't be built that can't fit
  284. int nClampedIndices = MIN( materialBatch.m_TriListIndices.Count(), 32766 );
  285. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, materialBatch.m_Verts.Count(), nClampedIndices );
  286. int vertID;
  287. // Send the vertices down to the hardware.
  288. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  289. {
  290. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  291. const Vector &pos = vert.m_Position;
  292. const Vector &normal = vert.m_Normal;
  293. const Vector4D &tangentS = vert.m_TangentS;
  294. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  295. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  296. Vector4D skinnedTangentS( 0.0f, 0.0f, 0.0f, vert.m_TangentS[3] );
  297. int k;
  298. for( k = 0; k < vert.m_NumBones; k++ )
  299. {
  300. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  301. Vector tmp;
  302. VectorTransform( pos, poseToWorld, tmp );
  303. skinnedPos += vert.m_BoneWeight[k] * tmp;
  304. VectorRotate( normal, poseToWorld, tmp );
  305. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  306. VectorRotate( tangentS.AsVector3D(), poseToWorld, tmp );
  307. skinnedTangentS.AsVector3D() += vert.m_BoneWeight[k] * tmp;
  308. }
  309. meshBuilder.Position3fv( &skinnedPos.x );
  310. meshBuilder.Normal3fv( &skinnedNormal.x );
  311. meshBuilder.TexCoord2fv( 0, &vert.m_TexCoord.x );
  312. meshBuilder.UserData( &skinnedTangentS.x );
  313. Vector color( 0.0f, 0.0f, 0.0f );
  314. float len;
  315. // check the length of the tangent S vector.
  316. len = tangentS.AsVector3D().Length();
  317. if( len < .9f || len > 1.1f )
  318. {
  319. color.Init( 1.0f, 0.0f, 0.0f );
  320. }
  321. // check the length of the normal.
  322. len = normal.Length();
  323. if( len < .9f || len > 1.1f )
  324. {
  325. color.Init( 1.0f, 0.0f, 0.0f );
  326. }
  327. // check the dot of tangent s and normal
  328. float dot = DotProduct( tangentS.AsVector3D(), normal );
  329. if( dot > .95 || dot < -.95 )
  330. {
  331. color.Init( 1.0f, 0.0f, 0.0f );
  332. }
  333. meshBuilder.Color3fv( color.Base() );
  334. meshBuilder.AdvanceVertex();
  335. }
  336. int i;
  337. // Set the indices down to the hardware.
  338. // Each triplet of indices is a triangle.
  339. for( i = indexStart; i < indexStart + nClampedIndices; i++ )
  340. {
  341. meshBuilder.FastIndex( materialBatch.m_TriListIndices[i] );
  342. }
  343. meshBuilder.End();
  344. pBuildMesh->Draw();
  345. indexStart += nClampedIndices;
  346. }
  347. }
  348. pRenderContext->MatrixMode( MATERIAL_MODEL );
  349. pRenderContext->PopMatrix();
  350. return 0;
  351. }
  352. int DebugDrawModelWireframe( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  353. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, const Vector &color, int flags )
  354. {
  355. // Make static so that we aren't reallocating everything all the time.
  356. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  357. static GetTriangles_Output_t tris;
  358. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  359. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  360. pRenderContext->MatrixMode( MATERIAL_MODEL );
  361. pRenderContext->PushMatrix();
  362. pRenderContext->LoadIdentity();
  363. CMeshBuilder meshBuilder;
  364. int batchID;
  365. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  366. {
  367. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  368. pRenderContext->Bind( g_materialWireframeVertexColor );
  369. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  370. int indexStart;
  371. for (indexStart = 0; indexStart < materialBatch.m_TriListIndices.Count(); )
  372. {
  373. // FIXME: this shouldn't be needed, models shouldn't be built that can't fit
  374. int nClampedIndices = MIN( materialBatch.m_TriListIndices.Count() - indexStart, 32766 );
  375. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, materialBatch.m_Verts.Count(), nClampedIndices );
  376. int vertID;
  377. // Send the vertices down to the hardware.
  378. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  379. {
  380. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  381. const Vector &pos = vert.m_Position;
  382. const Vector &normal = vert.m_Normal;
  383. const Vector4D &tangentS = vert.m_TangentS;
  384. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  385. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  386. Vector4D skinnedTangentS( 0.0f, 0.0f, 0.0f, vert.m_TangentS[3] );
  387. int k;
  388. for( k = 0; k < vert.m_NumBones; k++ )
  389. {
  390. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  391. Vector tmp;
  392. VectorTransform( pos, poseToWorld, tmp );
  393. skinnedPos += vert.m_BoneWeight[k] * tmp;
  394. VectorRotate( normal, poseToWorld, tmp );
  395. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  396. VectorRotate( tangentS.AsVector3D(), poseToWorld, tmp );
  397. skinnedTangentS.AsVector3D() += vert.m_BoneWeight[k] * tmp;
  398. }
  399. meshBuilder.Position3fv( &skinnedPos.x );
  400. meshBuilder.Normal3fv( &skinnedNormal.x );
  401. meshBuilder.TexCoord2fv( 0, &vert.m_TexCoord.x );
  402. meshBuilder.UserData( &skinnedTangentS.x );
  403. meshBuilder.Color3fv( color.Base() );
  404. meshBuilder.AdvanceVertex();
  405. }
  406. int i;
  407. // Set the indices down to the hardware.
  408. // Each triplet of indices is a triangle.
  409. for( i = indexStart; i < indexStart + nClampedIndices; i++ )
  410. {
  411. meshBuilder.FastIndex( materialBatch.m_TriListIndices[i] );
  412. }
  413. meshBuilder.End();
  414. pBuildMesh->Draw();
  415. indexStart += nClampedIndices;
  416. }
  417. }
  418. pRenderContext->MatrixMode( MATERIAL_MODEL );
  419. pRenderContext->PopMatrix();
  420. return 0;
  421. }
  422. void drawWeightIdentifier( matrix3x4_t& m, float flLength )
  423. {
  424. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  425. IMesh* pMesh = pRenderContext->GetDynamicMesh( );
  426. CMeshBuilder meshBuilder;
  427. const unsigned char white[3] = { 255, 255, 255 };
  428. const unsigned char black[3] = { 0, 0, 0 };
  429. Vector vecPoint;
  430. MatrixPosition( m, vecPoint );
  431. meshBuilder.Begin( pMesh, MATERIAL_TRIANGLES, 2 );
  432. meshBuilder.Color3ubv( black );
  433. meshBuilder.Position3f( vecPoint.x, vecPoint.y, vecPoint.z );
  434. meshBuilder.AdvanceVertex();
  435. meshBuilder.Color3ubv( black );
  436. meshBuilder.Position3f( vecPoint.x + flLength * 0.9f, vecPoint.y - flLength * 0.2f, vecPoint.z + flLength );
  437. meshBuilder.AdvanceVertex();
  438. meshBuilder.Color3ubv( black );
  439. meshBuilder.Position3f( vecPoint.x + flLength * 0.9f, vecPoint.y + flLength * 0.2f, vecPoint.z + flLength );
  440. meshBuilder.AdvanceVertex();
  441. meshBuilder.Color3ubv( white );
  442. meshBuilder.Position3f( vecPoint.x, vecPoint.y, vecPoint.z );
  443. meshBuilder.AdvanceVertex();
  444. meshBuilder.Color3ubv( white );
  445. meshBuilder.Position3f( vecPoint.x + flLength, vecPoint.y - flLength * 0.1f, vecPoint.z + flLength * 0.9f );
  446. meshBuilder.AdvanceVertex();
  447. meshBuilder.Color3ubv( white );
  448. meshBuilder.Position3f( vecPoint.x + flLength, vecPoint.y + flLength * 0.1f, vecPoint.z + flLength * 0.9f );
  449. meshBuilder.AdvanceVertex();
  450. meshBuilder.End();
  451. pMesh->Draw();
  452. }
  453. int g_BoneWeightInspectVert;
  454. debug_vert_weight_t g_BoneWeightInspectResults[3];
  455. int DebugDrawModelBoneWeights( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  456. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, int flags )
  457. {
  458. // Make static so that we aren't reallocating everything all the time.
  459. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  460. static GetTriangles_Output_t tris;
  461. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  462. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  463. pRenderContext->MatrixMode( MATERIAL_MODEL );
  464. pRenderContext->PushMatrix();
  465. pRenderContext->LoadIdentity();
  466. CMeshBuilder meshBuilder;
  467. Vector vecDebugPos;
  468. vecDebugPos.Init();
  469. int batchID;
  470. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  471. {
  472. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  473. pRenderContext->Bind( g_materialVertexColor );
  474. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  475. int indexStart;
  476. for (indexStart = 0; indexStart < materialBatch.m_TriListIndices.Count(); )
  477. {
  478. // FIXME: this shouldn't be needed, models shouldn't be built that can't fit
  479. int nClampedIndices = MIN( materialBatch.m_TriListIndices.Count(), 32766 );
  480. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, materialBatch.m_Verts.Count(), nClampedIndices );
  481. int vertID;
  482. // Send the vertices down to the hardware.
  483. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  484. {
  485. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  486. const Vector &pos = vert.m_Position;
  487. const Vector &normal = vert.m_Normal;
  488. const Vector4D &tangentS = vert.m_TangentS;
  489. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  490. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  491. Vector4D skinnedTangentS( 0.0f, 0.0f, 0.0f, vert.m_TangentS[3] );
  492. if ( vertID == g_BoneWeightInspectVert )
  493. {
  494. g_BoneWeightInspectResults[0].index = 0;
  495. g_BoneWeightInspectResults[0].flweight = 0;
  496. g_BoneWeightInspectResults[1].index = 0;
  497. g_BoneWeightInspectResults[1].flweight = 0;
  498. g_BoneWeightInspectResults[2].index = 0;
  499. g_BoneWeightInspectResults[2].flweight = 0;
  500. }
  501. int k;
  502. for( k = 0; k < vert.m_NumBones; k++ )
  503. {
  504. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  505. Vector tmp;
  506. VectorTransform( pos, poseToWorld, tmp );
  507. skinnedPos += vert.m_BoneWeight[k] * tmp;
  508. VectorRotate( normal, poseToWorld, tmp );
  509. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  510. VectorRotate( tangentS.AsVector3D(), poseToWorld, tmp );
  511. skinnedTangentS.AsVector3D() += vert.m_BoneWeight[k] * tmp;
  512. if ( vertID == g_BoneWeightInspectVert && k < 3 )
  513. {
  514. g_BoneWeightInspectResults[k].index = vert.m_BoneIndex[k];
  515. g_BoneWeightInspectResults[k].flweight = vert.m_BoneWeight[k];
  516. }
  517. }
  518. if ( vertID == g_BoneWeightInspectVert )
  519. {
  520. VectorCopy( skinnedPos, vecDebugPos );
  521. }
  522. meshBuilder.Position3fv( &skinnedPos.x );
  523. meshBuilder.Normal3fv( &skinnedNormal.x );
  524. meshBuilder.TexCoord2fv( 0, &vert.m_TexCoord.x );
  525. meshBuilder.UserData( &skinnedTangentS.x );
  526. if (g_viewerSettings.highlightBone >= 0)
  527. {
  528. float v = 0.0;
  529. for( k = 0; k < vert.m_NumBones; k++ )
  530. {
  531. if (vert.m_BoneIndex[k] == g_viewerSettings.highlightBone)
  532. {
  533. v = vert.m_BoneWeight[k];
  534. }
  535. }
  536. v = clamp( v, 0.0f, 1.0f );
  537. meshBuilder.Color4f( 1.0f - v, 1.0f, 1.0f - v, 0.5 );
  538. }
  539. else
  540. {
  541. switch( vert.m_NumBones )
  542. {
  543. case 0:
  544. meshBuilder.Color3f( 0.0f, 0.0f, 0.0f );
  545. break;
  546. case 1:
  547. meshBuilder.Color3f( 0.0f, 1.0f, 0.0f );
  548. break;
  549. case 2:
  550. meshBuilder.Color3f( 1.0f, 1.0f, 0.0f );
  551. break;
  552. case 3:
  553. meshBuilder.Color3f( 1.0f, 0.0f, 0.0f );
  554. break;
  555. default:
  556. meshBuilder.Color3f( 1.0f, 1.0f, 1.0f );
  557. break;
  558. }
  559. }
  560. meshBuilder.AdvanceVertex();
  561. }
  562. int i;
  563. // Set the indices down to the hardware.
  564. // Each triplet of indices is a triangle.
  565. for( i = indexStart; i < indexStart + nClampedIndices; i++ )
  566. {
  567. meshBuilder.FastIndex( materialBatch.m_TriListIndices[i] );
  568. }
  569. meshBuilder.End();
  570. pBuildMesh->Draw();
  571. indexStart += nClampedIndices;
  572. }
  573. }
  574. pRenderContext->MatrixMode( MATERIAL_MODEL );
  575. pRenderContext->PopMatrix();
  576. matrix3x4_t temp;
  577. temp.SetToIdentity();
  578. PositionMatrix( vecDebugPos, temp );
  579. drawWeightIdentifier( temp, 8 );
  580. return 0;
  581. }
  582. class CMatchedVert
  583. {
  584. public:
  585. CMatchedVert( const GetTriangles_Vertex_t &vert )
  586. {
  587. m_pos = vert.m_Position;
  588. m_bones = (vert.m_BoneIndex[0])
  589. + ((vert.m_BoneIndex[1] > 0 ? vert.m_BoneIndex[1] : 0 )<< 8)
  590. + ((vert.m_BoneIndex[2] > 0 ? vert.m_BoneIndex[1] : 0 )<< 16);
  591. m_count = 1;
  592. }
  593. class CMatchedVertLessFunc
  594. {
  595. public:
  596. bool Less( CMatchedVert const & lhs, CMatchedVert const & rhs, void *pContext )
  597. {
  598. float i1 = lhs.m_pos.x + lhs.m_pos.y + lhs.m_pos.z + lhs.m_bones;
  599. float i2 = rhs.m_pos.x + rhs.m_pos.y + rhs.m_pos.z + rhs.m_bones;
  600. return (i1 < i2);
  601. }
  602. };
  603. Vector m_pos;
  604. int m_bones;
  605. int m_count;
  606. };
  607. int DebugDrawModelVertColocation( IStudioRender *pStudioRender, DrawModelInfo_t& info,
  608. matrix3x4_t *pBoneToWorld, const Vector &modelOrigin, int flags )
  609. {
  610. // Make static so that we aren't reallocating everything all the time.
  611. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  612. static GetTriangles_Output_t tris;
  613. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  614. static DrawModelInfo_t cached_info;
  615. static CUtlSortVector< CMatchedVert, CMatchedVert::CMatchedVertLessFunc > sortedVector;
  616. if ( memcmp( &info, &cached_info, sizeof( DrawModelInfo_t ) ) )
  617. {
  618. sortedVector.RemoveAll( );
  619. cached_info = info;
  620. int batchID;
  621. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  622. {
  623. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  624. int vertID;
  625. // Send the vertices down to the hardware.
  626. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  627. {
  628. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  629. CMatchedVert mv( vert );
  630. int i = sortedVector.Find( mv );
  631. if (i == -1)
  632. {
  633. sortedVector.Insert( mv );
  634. }
  635. else
  636. {
  637. sortedVector[i].m_count++;
  638. }
  639. }
  640. }
  641. }
  642. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  643. pRenderContext->MatrixMode( MATERIAL_MODEL );
  644. pRenderContext->PushMatrix();
  645. pRenderContext->LoadIdentity();
  646. CMeshBuilder meshBuilder;
  647. // pRenderContext->DrawScreenSpaceRectangle( g_materialVertexColor, 0, 0, 64, 64, 0, 0, 1, 1, 1, 1 );
  648. int batchID;
  649. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  650. {
  651. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  652. pRenderContext->Bind( g_materialVertexColor );
  653. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  654. int indexStart;
  655. for (indexStart = 0; indexStart < materialBatch.m_TriListIndices.Count(); )
  656. {
  657. // FIXME: this shouldn't be needed, models shouldn't be built that can't fit
  658. int nClampedIndices = MIN( materialBatch.m_TriListIndices.Count() - indexStart, 32766 );
  659. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, materialBatch.m_Verts.Count(), nClampedIndices );
  660. int vertID;
  661. // Send the vertices down to the hardware.
  662. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  663. {
  664. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  665. CMatchedVert mv( vert );
  666. const Vector &pos = vert.m_Position;
  667. const Vector &normal = vert.m_Normal;
  668. const Vector4D &tangentS = vert.m_TangentS;
  669. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  670. Vector skinnedNormal( 0.0f, 0.0f, 0.0f );
  671. Vector4D skinnedTangentS( 0.0f, 0.0f, 0.0f, vert.m_TangentS[3] );
  672. int k;
  673. for( k = 0; k < vert.m_NumBones; k++ )
  674. {
  675. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  676. Vector tmp;
  677. VectorTransform( pos, poseToWorld, tmp );
  678. skinnedPos += vert.m_BoneWeight[k] * tmp;
  679. VectorRotate( normal, poseToWorld, tmp );
  680. skinnedNormal += vert.m_BoneWeight[k] * tmp;
  681. VectorRotate( tangentS.AsVector3D(), poseToWorld, tmp );
  682. skinnedTangentS.AsVector3D() += vert.m_BoneWeight[k] * tmp;
  683. }
  684. meshBuilder.Position3fv( &skinnedPos.x );
  685. meshBuilder.Normal3fv( &skinnedNormal.x );
  686. meshBuilder.TexCoord2fv( 0, &vert.m_TexCoord.x );
  687. meshBuilder.UserData( &skinnedTangentS.x );
  688. int i = sortedVector.Find( mv );
  689. switch( i >= 0 ? sortedVector[i].m_count : 0 )
  690. {
  691. case 0:
  692. meshBuilder.Color3f( 0.0f, 0.0f, 0.0f );
  693. break;
  694. case 1:
  695. meshBuilder.Color3f( 0.0f, 0.0f, 1.0f );
  696. break;
  697. case 2:
  698. meshBuilder.Color3f( 0.0f, 1.0f, 0.0f );
  699. break;
  700. case 3:
  701. meshBuilder.Color3f( 1.0f, 1.0f, 0.0f );
  702. break;
  703. default:
  704. meshBuilder.Color3f( 1.0f, 0.0f, 0.0f );
  705. break;
  706. }
  707. meshBuilder.AdvanceVertex();
  708. }
  709. int i;
  710. // Set the indices down to the hardware.
  711. // Each triplet of indices is a triangle.
  712. for( i = indexStart; i < indexStart + nClampedIndices; i++ )
  713. {
  714. meshBuilder.FastIndex( materialBatch.m_TriListIndices[i] );
  715. }
  716. meshBuilder.End();
  717. pBuildMesh->Draw();
  718. indexStart += nClampedIndices;
  719. }
  720. }
  721. pRenderContext->MatrixMode( MATERIAL_MODEL );
  722. pRenderContext->PopMatrix();
  723. return 0;
  724. }
  725. int DebugDrawModelTexCoord( IStudioRender *pStudioRender, const char *pMaterialName, const DrawModelInfo_t& info, matrix3x4_t *pBoneToWorld, float w, float h )
  726. {
  727. // Make static so that we aren't reallocating everything all the time.
  728. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  729. static GetTriangles_Output_t tris;
  730. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  731. CUtlVector<int> batchList;
  732. for( int batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  733. {
  734. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  735. if ( !materialBatch.m_Verts.Count() || V_stricmp(materialBatch.m_pMaterial->GetName(), pMaterialName) )
  736. continue;
  737. batchList.AddToTail(batchID);
  738. }
  739. if ( !batchList.Count() )
  740. return 0;
  741. bool bFound = false;
  742. IMaterialVar *pBaseVar = g_materialDebugCopyBaseTexture->FindVar( "$basetexture", &bFound, true );
  743. if ( !bFound )
  744. return 0;
  745. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchList[0]];
  746. IMaterialVar *pVar = materialBatch.m_pMaterial->FindVar( "$basetexture", &bFound, true );
  747. if ( !bFound )
  748. return 0;
  749. pBaseVar->SetTextureValue( pVar->GetTextureValue() );
  750. CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
  751. pRenderContext->OverrideDepthEnable( false, false );
  752. pRenderContext->MatrixMode( MATERIAL_MODEL );
  753. pRenderContext->PushMatrix();
  754. pRenderContext->LoadIdentity();
  755. pRenderContext->MatrixMode( MATERIAL_PROJECTION );
  756. pRenderContext->PushMatrix();
  757. pRenderContext->LoadIdentity();
  758. pRenderContext->Ortho( 0, h, w, 0, -1, 1 );
  759. pRenderContext->MatrixMode( MATERIAL_VIEW );
  760. pRenderContext->PushMatrix();
  761. pRenderContext->LoadIdentity();
  762. CMeshBuilder meshBuilder;
  763. // now render a single quad with the base texture on it
  764. {
  765. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchList[0]];
  766. //pRenderContext->Bind( materialBatch.m_pMaterial );
  767. pRenderContext->Bind( g_materialDebugCopyBaseTexture );
  768. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  769. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, 4, 6 );
  770. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[0];
  771. //const Vector &pos = vert.m_Position;
  772. const Vector &normal = vert.m_Normal;
  773. const Vector4D &tangentS = vert.m_TangentS;
  774. Vector uv0(0,0,0), uv1(1,0,0), uv2(1, 1, 0), uv3(0,1,0);
  775. Vector *pUV[] = {&uv0, &uv1, &uv2, &uv3};
  776. for ( int i = 0;i < 4; i++ )
  777. {
  778. Vector p = *pUV[i];
  779. p.x *= w;
  780. p.y *= h;
  781. meshBuilder.Position3fv( &p.x );
  782. meshBuilder.Normal3fv( &normal.x );
  783. meshBuilder.TexCoord2fv( 0, pUV[i]->Base() );
  784. meshBuilder.UserData( &tangentS.x );
  785. meshBuilder.Color3f( 1.0f, 1.0f, 1.0f );
  786. meshBuilder.AdvanceVertex();
  787. }
  788. meshBuilder.FastIndex( 0 );
  789. meshBuilder.FastIndex( 1 );
  790. meshBuilder.FastIndex( 2 );
  791. meshBuilder.FastIndex( 0 );
  792. meshBuilder.FastIndex( 2 );
  793. meshBuilder.FastIndex( 3 );
  794. meshBuilder.End();
  795. pBuildMesh->Draw();
  796. }
  797. // now draw coverage - show which UV space is used more than once
  798. #if 0
  799. for( int i = 0; i < batchList.Count(); i++ )
  800. {
  801. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchList[i]];
  802. //pRenderContext->Bind( g_materialWireframeVertexColorNoCull );
  803. pRenderContext->Bind( g_materialVertexColorAdditive );
  804. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  805. // FIXME: this shouldn't be needed, models shouldn't be built that can't fit
  806. int nClampedIndices = MIN( materialBatch.m_TriListIndices.Count(), 32766 );
  807. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, materialBatch.m_Verts.Count(), nClampedIndices );
  808. int vertID;
  809. // Send the vertices down to the hardware.
  810. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  811. {
  812. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  813. const Vector &normal = vert.m_Normal;
  814. const Vector4D &tangentS = vert.m_TangentS;
  815. Vector p;
  816. p.x = vert.m_TexCoord.x * w;
  817. p.y = vert.m_TexCoord.y * h;
  818. p.z = 0;
  819. meshBuilder.Position3fv( &p.x );
  820. meshBuilder.Normal3fv( &normal.x );
  821. meshBuilder.UserData( &tangentS.x );
  822. meshBuilder.Color3f( 0.25f, 0.0f, 0.0f );
  823. meshBuilder.AdvanceVertex();
  824. }
  825. int i;
  826. // Set the indices down to the hardware.
  827. // Each triplet of indices is a triangle.
  828. for( i = 0; i < nClampedIndices; i++ )
  829. {
  830. meshBuilder.FastIndex( materialBatch.m_TriListIndices[i] );
  831. }
  832. meshBuilder.End();
  833. pBuildMesh->Draw();
  834. }
  835. #endif
  836. const color32 batchColor = {0,255,255,0};
  837. // now draw all batches with the matching material in wireframe over the render of the base texture
  838. for( int i = 0; i < batchList.Count(); i++ )
  839. {
  840. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchList[i]];
  841. pRenderContext->Bind( g_materialWireframeVertexColorNoCull );
  842. IMesh *pBuildMesh = pRenderContext->GetDynamicMesh( false );
  843. // FIXME: this shouldn't be needed, models shouldn't be built that can't fit
  844. int nClampedIndices = MIN( materialBatch.m_TriListIndices.Count(), 32766 );
  845. meshBuilder.Begin( pBuildMesh, MATERIAL_TRIANGLES, materialBatch.m_Verts.Count(), nClampedIndices );
  846. int vertID;
  847. // Send the vertices down to the hardware.
  848. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  849. {
  850. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  851. const Vector &normal = vert.m_Normal;
  852. const Vector4D &tangentS = vert.m_TangentS;
  853. Vector p;
  854. p.x = vert.m_TexCoord.x * w;
  855. p.y = vert.m_TexCoord.y * h;
  856. p.z = 0;
  857. meshBuilder.Position3fv( &p.x );
  858. meshBuilder.Normal3fv( &normal.x );
  859. meshBuilder.UserData( &tangentS.x );
  860. meshBuilder.Color4ubv( &batchColor.r );
  861. meshBuilder.AdvanceVertex();
  862. }
  863. // Set the indices down to the hardware.
  864. // Each triplet of indices is a triangle.
  865. for(int j = 0; j < nClampedIndices; j++ )
  866. {
  867. meshBuilder.FastIndex( materialBatch.m_TriListIndices[j] );
  868. }
  869. meshBuilder.End();
  870. pBuildMesh->Draw();
  871. }
  872. pRenderContext->MatrixMode( MATERIAL_VIEW );
  873. pRenderContext->PopMatrix();
  874. pRenderContext->MatrixMode( MATERIAL_PROJECTION );
  875. pRenderContext->PopMatrix();
  876. pRenderContext->MatrixMode( MATERIAL_MODEL );
  877. pRenderContext->PopMatrix();
  878. return 0;
  879. }
  880. int DebugModelVertExtents( IStudioRender *pStudioRender, DrawModelInfo_t& info, matrix3x4_t *pBoneToWorld, Vector &vecMin, Vector &vecMax )
  881. {
  882. // Make static so that we aren't reallocating everything all the time.
  883. // TODO: make sure that this actually keeps us from reallocating inside of GetTriangles.
  884. static GetTriangles_Output_t tris;
  885. vecMin.Init( 999999,999999,999999);
  886. vecMax.Init( -999999,-999999,-999999);
  887. pStudioRender->GetTriangles( info, pBoneToWorld, tris );
  888. int batchID;
  889. for( batchID = 0; batchID < tris.m_MaterialBatches.Count(); batchID++ )
  890. {
  891. GetTriangles_MaterialBatch_t &materialBatch = tris.m_MaterialBatches[batchID];
  892. int vertID;
  893. // Send the vertices down to the hardware.
  894. for( vertID = 0; vertID < materialBatch.m_Verts.Count(); vertID++ )
  895. {
  896. GetTriangles_Vertex_t &vert = materialBatch.m_Verts[vertID];
  897. const Vector &pos = vert.m_Position;
  898. Vector skinnedPos( 0.0f, 0.0f, 0.0f );
  899. int k;
  900. for( k = 0; k < vert.m_NumBones; k++ )
  901. {
  902. const matrix3x4_t &poseToWorld = tris.m_PoseToWorld[ vert.m_BoneIndex[k] ];
  903. Vector tmp;
  904. VectorTransform( pos, poseToWorld, tmp );
  905. skinnedPos += vert.m_BoneWeight[k] * tmp;
  906. }
  907. VectorMin( skinnedPos, vecMin, vecMin );
  908. VectorMax( skinnedPos, vecMax, vecMax );
  909. }
  910. }
  911. return 0;
  912. }