[Bf-blender-cvs] [d21ed9a] blender-v2.77-release: Fix T47893: BGE crashes w/ generated mesh data

Campbell Barton noreply at git.blender.org
Tue Apr 5 10:38:10 CEST 2016


Commit: d21ed9af211c0e0f691761174b11653cb8c5e0ec
Author: Campbell Barton
Date:   Wed Mar 23 23:37:08 2016 +1100
Branches: blender-v2.77-release
https://developer.blender.org/rBd21ed9af211c0e0f691761174b11653cb8c5e0ec

Fix T47893: BGE crashes w/ generated mesh data

===================================================================

M	source/gameengine/Physics/Bullet/CcdPhysicsController.cpp

===================================================================

diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 89806d8..c79e1c2 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -1895,10 +1895,10 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm,
 		for (int p2 = 0; p2 < numpolys; p2++) {
 			MFace *mf = &mface[p2];
 			const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-			RAS_Polygon *poly = meshobj->GetPolygon(origi);
+			RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
 
 			// only add polygons that have the collision flag set
-			if (poly->IsCollider()) {
+			if (poly && poly->IsCollider()) {
 				if (!vert_tag_array[mf->v1]) {
 					vert_tag_array[mf->v1] = true;
 					tot_bt_verts++;
@@ -1930,7 +1930,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm,
 		for (int p2 = 0; p2 < numpolys; p2++) {
 			MFace *mf = &mface[p2];
 			const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-			RAS_Polygon *poly = meshobj->GetPolygon(origi);
+			RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
 
 			// only add polygons that have the collisionflag set
 			if (poly->IsCollider()) {
@@ -1973,10 +1973,10 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm,
 		for (int p2 = 0; p2 < numpolys; p2++) {
 			MFace *mf = &mface[p2];
 			const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-			RAS_Polygon *poly = meshobj->GetPolygon(origi);
+			RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
 
 			// only add polygons that have the collision flag set
-			if (poly->IsCollider()) {
+			if (poly && poly->IsCollider()) {
 				if (!vert_tag_array[mf->v1]) {
 					vert_tag_array[mf->v1] = true;
 					vert_remap_array[mf->v1] = tot_bt_verts;
@@ -2025,10 +2025,10 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject *meshobj, DerivedMesh *dm,
 			MFace *mf = &mface[p2];
 			MTFace *tf = (tface) ? &tface[p2] : NULL;
 			const int origi = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, p2) : p2;
-			RAS_Polygon *poly = meshobj->GetPolygon(origi);
+			RAS_Polygon *poly = (origi != ORIGINDEX_NONE) ? meshobj->GetPolygon(origi) : NULL;
 
 			// only add polygons that have the collisionflag set
-			if (poly->IsCollider()) {
+			if (poly && poly->IsCollider()) {
 				MVert *v1 = &mvert[mf->v1];
 				MVert *v2 = &mvert[mf->v2];
 				MVert *v3 = &mvert[mf->v3];




More information about the Bf-blender-cvs mailing list