Fix T38335: incorrect triangle index in raycast result

Previously we forgot to do a special operation for indexes to convert a quad to two triangles.
This commit is contained in:
Porteries Tristan 2015-05-08 20:55:50 +02:00
parent a08d90f070
commit 6ee0327594
Notes: blender-bot 2023-02-14 11:18:04 +01:00
Referenced by issue #38335, Raycast and replaceMesh
1 changed files with 7 additions and 3 deletions

View File

@ -2382,7 +2382,6 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject *gameobj, class RA
* RAS Mesh Update
*
* */
/* Note!, gameobj can be NULL here */
/* transverts are only used for deformed RAS_Meshes, the RAS_TexVert data
@ -2437,7 +2436,7 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject *gameobj, class RA
m_polygonIndexArray.resize(tot_bt_tris);
for (int p = 0; p < numpolys; p++) {
for (int p = 0; p < numpolys;) {
RAS_Polygon *poly = meshobj->GetPolygon(p);
if (poly->IsCollider()) {
@ -2466,7 +2465,12 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject *gameobj, class RA
*tri_pt++ = vert_remap_array[v_orig];
}
}
m_polygonIndexArray[p] = p; /* dumb counting */
m_polygonIndexArray[p] = p;
if (poly->VertexCount() == 4) {
// if the poly is a quad we transform it in two triangles
m_polygonIndexArray[p + 1] = p++;
}
p++;
}
}