@@ -1142,111 +1142,239 @@ void CSkeletonX_ext::_FillVerticesHW4W(const Fmatrix& view, CSkeletonWallmark& w
11421142
11431143#else // USE_DX10
11441144
1145- void CSkeletonX_ext::_FillVerticesHW1W (const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal,
1146- float size, Fvisual* V, u16 * indices, CBoneData::FacesVec& faces)
1145+ void CSkeletonX_ext::_FillVerticesHW1W (const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal,
1146+ float size, Fvisual* V, u16 * indices, CBoneData::FacesVec& faces)
1147+ {
1148+ vertHW_1W* vertices;
1149+ CHK_DX (V->p_rm_Vertices ->Lock (V->vBase , V->vCount , (void **)&vertices, D3DLOCK_READONLY));
1150+ for (auto it = faces.begin (); it != faces.end (); ++it)
11471151 {
1148- vertHW_1W* vertices;
1149- CHK_DX (V->p_rm_Vertices ->Lock (V->vBase , V->vCount , (void **)&vertices, D3DLOCK_READONLY));
1150- for (auto it = faces.begin (); it != faces.end (); it++)
1152+ Fvector p[3 ];
1153+ u32 idx = *it * 3 ;
1154+ CSkeletonWallmark::WMFace F;
1155+
1156+ for (u32 k = 0 ; k < 3 ; k++)
1157+ {
1158+ vertHW_1W& vert = vertices[indices[idx + k]];
1159+ F.bone_id [k][0 ] = vert.get_bone ();
1160+ F.bone_id [k][1 ] = F.bone_id [k][0 ];
1161+ F.bone_id [k][2 ] = F.bone_id [k][0 ];
1162+ F.bone_id [k][3 ] = F.bone_id [k][0 ];
1163+ F.weight [k][0 ] = 0 .f ;
1164+ F.weight [k][1 ] = 0 .f ;
1165+ F.weight [k][2 ] = 0 .f ;
1166+
1167+ const Fmatrix& xform = Parent->LL_GetBoneInstance (F.bone_id [k][0 ]).mRenderTransform ;
1168+ vert.get_pos (F.vert [k]);
1169+ xform.transform_tiny (p[k], F.vert [k]);
1170+ }
1171+ Fvector test_normal;
1172+ test_normal.mknormal (p[0 ], p[1 ], p[2 ]);
1173+ float cosa = test_normal.dotproduct (normal);
1174+ if (cosa < EPS)
1175+ continue ;
1176+ if (CDB::TestSphereTri (wm.ContactPoint (), size, p))
11511177 {
1152- Fvector p[3 ];
1153- u32 idx = (*it) * 3 ;
1154- CSkeletonWallmark::WMFace F;
1178+ Fvector UV;
11551179 for (u32 k = 0 ; k < 3 ; k++)
11561180 {
1157- vertHW_1W& vert = vertices[indices[idx + k]];
1158- F.bone_id [k][0 ] = vert.get_bone ();
1159- F.bone_id [k][1 ] = F.bone_id [k][0 ];
1160- F.weight [k] = 0 .f ;
1161- const Fmatrix& xform = Parent->LL_GetBoneInstance (F.bone_id [k][0 ]).mRenderTransform ;
1162- vert.get_pos (F.vert [k]);
1163- xform.transform_tiny (p[k], F.vert [k]);
1164- }
1165- Fvector test_normal;
1166- test_normal.mknormal (p[0 ], p[1 ], p[2 ]);
1167- float cosa = test_normal.dotproduct (normal);
1168- if (cosa < EPS)
1169- continue ;
1170- if (CDB::TestSphereTri (wm.ContactPoint (), size, p))
1171- {
1172- Fvector UV;
1173- for (u32 k = 0 ; k < 3 ; k++)
1174- {
1175- Fvector2& uv = F.uv [k];
1176- view.transform_tiny (UV, p[k]);
1177- uv.x = (1 + UV.x ) * .5f ;
1178- uv.y = (1 - UV.y ) * .5f ;
1179- }
1180- wm.m_Faces .push_back (F);
1181+ Fvector2& uv = F.uv [k];
1182+ view.transform_tiny (UV, p[k]);
1183+ uv.x = (1 + UV.x ) * .5f ;
1184+ uv.y = (1 - UV.y ) * .5f ;
11811185 }
1186+ wm.m_Faces .push_back (F);
11821187 }
1183- CHK_DX (V->p_rm_Vertices ->Unlock ());
11841188 }
1185- void CSkeletonX_ext::_FillVerticesHW2W (const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal,
1186- float size, Fvisual* V, u16 * indices, CBoneData::FacesVec& faces)
1189+ CHK_DX (V->p_rm_Vertices ->Unlock ());
1190+ }
1191+
1192+ void CSkeletonX_ext::_FillVerticesHW2W (const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal,
1193+ float size, Fvisual* V, u16 * indices, CBoneData::FacesVec& faces)
1194+ {
1195+ vertHW_2W* vertices;
1196+ CHK_DX (V->p_rm_Vertices ->Lock (V->vBase , V->vCount , (void **)&vertices, D3DLOCK_READONLY));
1197+
1198+ for (auto it = faces.begin (); it != faces.end (); ++it)
11871199 {
1188- vertHW_2W* vertices;
1189- CHK_DX (V->p_rm_Vertices ->Lock (V->vBase , V->vCount , (void **)&vertices, D3DLOCK_READONLY));
1200+ Fvector p[3 ];
1201+ u32 idx = *it * 3 ;
1202+ CSkeletonWallmark::WMFace F;
11901203
1191- for (auto it = faces. begin (); it != faces. end (); ++it )
1204+ for (u32 k = 0 ; k < 3 ; k++ )
11921205 {
1193- Fvector p[3 ];
1194- u32 idx = (*it) * 3 ;
1195- CSkeletonWallmark::WMFace F;
1206+ Fvector P0, P1;
11961207
1208+ vertHW_2W& vert = vertices[indices[idx + k]];
1209+ F.bone_id [k][0 ] = vert.get_bone (0 );
1210+ F.bone_id [k][1 ] = vert.get_bone (1 );
1211+ F.bone_id [k][2 ] = F.bone_id [k][1 ];
1212+ F.bone_id [k][3 ] = F.bone_id [k][1 ];
1213+ F.weight [k][0 ] = vert.get_weight ();
1214+ F.weight [k][1 ] = 0 .f ;
1215+ F.weight [k][2 ] = 0 .f ;
1216+
1217+ Fmatrix& xform0 = Parent->LL_GetBoneInstance (F.bone_id [k][0 ]).mRenderTransform ;
1218+ Fmatrix& xform1 = Parent->LL_GetBoneInstance (F.bone_id [k][1 ]).mRenderTransform ;
1219+ vert.get_pos (F.vert [k]);
1220+ xform0.transform_tiny (P0, F.vert [k]);
1221+ xform1.transform_tiny (P1, F.vert [k]);
1222+ p[k].lerp (P0, P1, F.weight [k][0 ]);
1223+ }
1224+ Fvector test_normal;
1225+ test_normal.mknormal (p[0 ], p[1 ], p[2 ]);
1226+ float cosa = test_normal.dotproduct (normal);
1227+ if (cosa < EPS) continue ;
1228+
1229+ if (CDB::TestSphereTri (wm.ContactPoint (), size, p))
1230+ {
1231+ Fvector UV;
11971232 for (u32 k = 0 ; k < 3 ; k++)
11981233 {
1199- Fvector P0, P1;
1200- vertHW_2W& vert = vertices[indices[idx + k]];
1201- F.bone_id [k][0 ] = vert.get_bone (0 );
1202- F.bone_id [k][1 ] = vert.get_bone (1 );
1203- F.weight [k] = vert.get_weight ();
1204- Fmatrix& xform0 = Parent->LL_GetBoneInstance (F.bone_id [k][0 ]).mRenderTransform ;
1205- Fmatrix& xform1 = Parent->LL_GetBoneInstance (F.bone_id [k][1 ]).mRenderTransform ;
1206- vert.get_pos (F.vert [k]);
1207- xform0.transform_tiny (P0, F.vert [k]);
1208- xform1.transform_tiny (P1, F.vert [k]);
1209- p[k].lerp (P0, P1, F.weight [k]);
1234+ Fvector2& uv = F.uv [k];
1235+ view.transform_tiny (UV, p[k]);
1236+ uv.x = (1 + UV.x ) * .5f ;
1237+ uv.y = (1 - UV.y ) * .5f ;
12101238 }
1211- Fvector test_normal;
1212- test_normal.mknormal (p[0 ], p[1 ], p[2 ]);
1213- float cosa = test_normal.dotproduct (normal);
1214- if (cosa < EPS)
1215- continue ;
1239+ wm.m_Faces .push_back (F);
1240+ }
1241+ }
1242+ CHK_DX (V->p_rm_Vertices ->Unlock ());
1243+ }
1244+
1245+ void CSkeletonX_ext::_FillVerticesHW3W (const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal,
1246+ float size, Fvisual* V, u16 * indices, CBoneData::FacesVec& faces)
1247+ {
1248+ vertHW_3W* vertices;
1249+ CHK_DX (V->p_rm_Vertices ->Lock (V->vBase , V->vCount , (void **)&vertices, D3DLOCK_READONLY));
1250+
1251+ for (auto it = faces.begin (); it != faces.end (); ++it)
1252+ {
1253+ Fvector p[3 ];
1254+ u32 idx = (*it) * 3 ;
1255+ CSkeletonWallmark::WMFace F;
12161256
1217- if (CDB::TestSphereTri (wm.ContactPoint (), size, p))
1257+ for (u32 k = 0 ; k < 3 ; k++)
1258+ {
1259+ vertHW_3W& vert = vertices[indices[idx + k]];
1260+ F.bone_id [k][0 ] = vert.get_bone (0 );
1261+ F.bone_id [k][1 ] = vert.get_bone (1 );
1262+ F.bone_id [k][2 ] = vert.get_bone (2 );
1263+ F.bone_id [k][3 ] = F.bone_id [k][2 ];
1264+ F.weight [k][0 ] = vert.get_weight0 ();
1265+ F.weight [k][1 ] = vert.get_weight1 ();
1266+ F.weight [k][2 ] = 0 .f ;
1267+ vert.get_pos (F.vert [k]);
1268+ vert.get_pos_bones (p[k], Parent);
1269+ }
1270+ Fvector test_normal;
1271+ test_normal.mknormal (p[0 ], p[1 ], p[2 ]);
1272+ float cosa = test_normal.dotproduct (normal);
1273+ if (cosa < EPS)
1274+ continue ;
1275+
1276+ if (CDB::TestSphereTri (wm.ContactPoint (), size, p))
1277+ {
1278+ Fvector UV;
1279+ for (u32 k = 0 ; k < 3 ; k++)
12181280 {
1219- Fvector UV;
1220- for (u32 k = 0 ; k < 3 ; k++)
1221- {
1222- Fvector2& uv = F.uv [k];
1223- view.transform_tiny (UV, p[k]);
1224- uv.x = (1 + UV.x ) * .5f ;
1225- uv.y = (1 - UV.y ) * .5f ;
1226- }
1227- wm.m_Faces .push_back (F);
1281+ Fvector2& uv = F.uv [k];
1282+ view.transform_tiny (UV, p[k]);
1283+ uv.x = (1 + UV.x ) * .5f ;
1284+ uv.y = (1 - UV.y ) * .5f ;
12281285 }
1286+ wm.m_Faces .push_back (F);
12291287 }
1230- CHK_DX (V->p_rm_Vertices ->Unlock ());
12311288 }
1289+ CHK_DX (V->p_rm_Vertices ->Unlock ());
1290+ }
12321291
1233- void CSkeletonX_ext::_FillVerticesHW3W (const Fmatrix& /* view*/ , CSkeletonWallmark& /* wm */ , const Fvector& /* normal*/ ,
1234- float /* size*/ , Fvisual* /* V */ , u16 * /* indices*/ , CBoneData::FacesVec& /* faces*/ )
1235- {
1236- R_ASSERT2 ( 0 , " CSkeletonX_ext::_FillVerticesHW3W not implemented " ) ;
1237- }
1292+ void CSkeletonX_ext::_FillVerticesHW4W (const Fmatrix& view, CSkeletonWallmark& wm , const Fvector& normal,
1293+ float size, Fvisual* V , u16 * indices, CBoneData::FacesVec& faces)
1294+ {
1295+ vertHW_4W* vertices ;
1296+ CHK_DX (V-> p_rm_Vertices -> Lock (V-> vBase , V-> vCount , ( void **)&vertices, D3DLOCK_READONLY));
12381297
1239- void CSkeletonX_ext::_FillVerticesHW4W (const Fmatrix& /* view*/ , CSkeletonWallmark& /* wm*/ , const Fvector& /* normal*/ ,
1240- float /* size*/ , Fvisual* /* V*/ , u16 * /* indices*/ , CBoneData::FacesVec& /* faces*/ )
1298+ for (auto it = faces.begin (); it != faces.end (); ++it)
12411299 {
1242- R_ASSERT2 (0 , " CSkeletonX_ext::_FillVerticesHW4W not implemented" );
1300+ Fvector p[3 ];
1301+ u32 idx = (*it) * 3 ;
1302+ CSkeletonWallmark::WMFace F;
1303+
1304+ for (u32 k = 0 ; k < 3 ; k++)
1305+ {
1306+ vertHW_4W& vert = vertices[indices[idx + k]];
1307+ F.bone_id [k][0 ] = vert.get_bone (0 );
1308+ F.bone_id [k][1 ] = vert.get_bone (1 );
1309+ F.bone_id [k][2 ] = vert.get_bone (2 );
1310+ F.bone_id [k][3 ] = vert.get_bone (3 );
1311+ F.weight [k][0 ] = vert.get_weight0 ();
1312+ F.weight [k][1 ] = vert.get_weight1 ();
1313+ F.weight [k][2 ] = vert.get_weight2 ();
1314+ vert.get_pos (F.vert [k]);
1315+ vert.get_pos_bones (p[k], Parent);
1316+ }
1317+ Fvector test_normal;
1318+ test_normal.mknormal (p[0 ], p[1 ], p[2 ]);
1319+ float cosa = test_normal.dotproduct (normal);
1320+ if (cosa < EPS)
1321+ continue ;
1322+
1323+ if (CDB::TestSphereTri (wm.ContactPoint (), size, p))
1324+ {
1325+ Fvector UV;
1326+ for (u32 k = 0 ; k < 3 ; k++)
1327+ {
1328+ Fvector2& uv = F.uv [k];
1329+ view.transform_tiny (UV, p[k]);
1330+ uv.x = (1 + UV.x ) * .5f ;
1331+ uv.y = (1 - UV.y ) * .5f ;
1332+ }
1333+ wm.m_Faces .push_back (F);
1334+ }
12431335 }
1336+ CHK_DX (V->p_rm_Vertices ->Unlock ());
1337+ }
12441338#endif // USE_DX10
12451339
1246- void CSkeletonX_ext::_FillVertices (const Fmatrix& /* view*/ , CSkeletonWallmark& /* wm */ , const Fvector& /* normal*/ ,
1247- float /* size*/ , Fvisual* /* V */ , u16 /* bone_id*/ , u32 /* iBase*/ , u32 /* iCount*/ )
1340+ void CSkeletonX_ext::_FillVertices (const Fmatrix& view, CSkeletonWallmark& wm , const Fvector& normal,
1341+ float size, Fvisual* V , u16 bone_id, u32 iBase, u32 /* iCount*/ )
12481342{
1249- R_ASSERT2 (0 , " CSkeletonX_ext::_FillVertices not implemented" );
1343+ VERIFY (Parent && ChildIDX != u16 (-1 ));
1344+ CBoneData& BD = Parent->LL_GetData (bone_id);
1345+ CBoneData::FacesVec* faces = &BD.child_faces [ChildIDX];
1346+ u16 * indices = nullptr ;
1347+ #if defined(USE_DX10) || defined(USE_DX11)
1348+ indices = *m_Indices;
1349+ #else // USE_DX10
1350+ CHK_DX (V->p_rm_Indices ->Lock (0 , V->dwPrimitives * 3 , (void **)&indices, D3DLOCK_READONLY));
1351+ // fill vertices
1352+ switch (RenderMode)
1353+ {
1354+ case RM_SKINNING_SOFT:
1355+ #endif // USE_DX10
1356+ if (*Vertices1W) _FillVerticesSoft1W (view, wm, normal, size, indices + iBase, *faces);
1357+ else if (*Vertices2W) _FillVerticesSoft2W (view, wm, normal, size, indices + iBase, *faces);
1358+ else if (*Vertices3W) _FillVerticesSoft3W (view, wm, normal, size, indices + iBase, *faces);
1359+ else
1360+ {
1361+ VERIFY (!!*Vertices4W);
1362+ _FillVerticesSoft4W (view, wm, normal, size, indices + iBase, *faces);
1363+ }
1364+ #if !defined(USE_DX10) && !defined(USE_DX11)
1365+ break ;
1366+ case RM_SINGLE:
1367+ case RM_SKINNING_1B: _FillVerticesHW1W (view, wm, normal, size, V, indices + iBase, *faces);
1368+ break ;
1369+ case RM_SKINNING_2B: _FillVerticesHW2W (view, wm, normal, size, V, indices + iBase, *faces);
1370+ break ;
1371+ case RM_SKINNING_3B: _FillVerticesHW3W (view, wm, normal, size, V, indices + iBase, *faces);
1372+ break ;
1373+ case RM_SKINNING_4B: _FillVerticesHW4W (view, wm, normal, size, V, indices + iBase, *faces);
1374+ break ;
1375+ }
1376+ CHK_DX (V->p_rm_Indices ->Unlock ());
1377+ #endif // USE_DX10
12501378}
12511379/*
12521380void CSkeletonX_ext::_FillVertices(const Fmatrix& view, CSkeletonWallmark& wm, const Fvector& normal, float size,
0 commit comments