[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40882] trunk/blender: fix crash for recent navmesh edits when setting a non-mesh object to a navmesh .
Campbell Barton
ideasman42 at gmail.com
Sun Oct 9 23:43:13 CEST 2011
Revision: 40882
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40882
Author: campbellbarton
Date: 2011-10-09 21:43:13 +0000 (Sun, 09 Oct 2011)
Log Message:
-----------
fix crash for recent navmesh edits when setting a non-mesh object to a navmesh.
also minor cleanup.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/properties_game.py
trunk/blender/source/blender/blenkernel/CMakeLists.txt
trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
trunk/blender/source/blender/makesrna/intern/rna_object.c
Modified: trunk/blender/release/scripts/startup/bl_ui/properties_game.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_game.py 2011-10-09 21:13:07 UTC (rev 40881)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_game.py 2011-10-09 21:43:13 UTC (rev 40882)
@@ -47,8 +47,9 @@
layout.prop(game, "physics_type")
layout.separator()
- #if game.physics_type == 'DYNAMIC':
- if game.physics_type in {'DYNAMIC', 'RIGID_BODY'}:
+ physics_type = game.physics_type
+
+ if physics_type in {'DYNAMIC', 'RIGID_BODY'}:
split = layout.split()
col = split.column()
@@ -108,7 +109,7 @@
col.prop(game, "lock_rotation_y", text="Y")
col.prop(game, "lock_rotation_z", text="Z")
- elif game.physics_type == 'SOFT_BODY':
+ elif physics_type == 'SOFT_BODY':
col = layout.column()
col.prop(game, "use_actor")
col.prop(game, "use_ghost")
@@ -143,7 +144,7 @@
sub.active = (soft.use_cluster_rigid_to_softbody or soft.use_cluster_soft_to_softbody)
sub.prop(soft, "cluster_iterations", text="Iterations")
- elif game.physics_type == 'STATIC':
+ elif physics_type == 'STATIC':
col = layout.column()
col.prop(game, "use_actor")
col.prop(game, "use_ghost")
@@ -164,9 +165,10 @@
subsub.active = game.use_anisotropic_friction
subsub.prop(game, "friction_coefficients", text="", slider=True)
- elif game.physics_type in {'SENSOR', 'INVISIBLE', 'NO_COLLISION', 'OCCLUDE'}:
+ elif physics_type in {'SENSOR', 'INVISIBLE', 'NO_COLLISION', 'OCCLUDE'}:
layout.prop(ob, "hide_render", text="Invisible")
- elif game.physics_type == 'NAVMESH':
+
+ elif physics_type == 'NAVMESH':
layout.operator("mesh.assign_navpolygon")
layout.operator("mesh.assign_new_navpolygon")
Modified: trunk/blender/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenkernel/CMakeLists.txt 2011-10-09 21:13:07 UTC (rev 40881)
+++ trunk/blender/source/blender/blenkernel/CMakeLists.txt 2011-10-09 21:43:13 UTC (rev 40882)
@@ -353,7 +353,7 @@
if(WITH_GAMEENGINE)
list(APPEND INC_SYS
- ../../../extern/recastnavigation
+ ../../../extern/recastnavigation
)
list(APPEND SRC
intern/navmesh_conversion.c
Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2011-10-09 21:13:07 UTC (rev 40881)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c 2011-10-09 21:43:13 UTC (rev 40882)
@@ -2113,7 +2113,7 @@
#ifdef WITH_GAMEENGINE
/* NavMesh - this is a hack but saves having a NavMesh modifier */
- if (ob->body_type == OB_BODY_TYPE_NAVMESH && finaldm->type == DM_TYPE_CDDM) {
+ if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) {
DerivedMesh *tdm;
tdm= navmesh_dm_createNavMeshForVisualization(finaldm);
if (finaldm != tdm) {
@@ -2966,7 +2966,7 @@
return (a & (1 << b)) >> b;
}
-BM_INLINE void navmesh_intToCol(int i, float* col)
+static void navmesh_intToCol(int i, float* col)
{
int r = navmesh_bit(i, 0) + navmesh_bit(i, 3) * 2 + 1;
int g = navmesh_bit(i, 1) + navmesh_bit(i, 4) * 2 + 1;
@@ -3034,8 +3034,8 @@
}
static void navmesh_DM_drawFacesSolid(DerivedMesh *dm,
- float (*partial_redraw_planes)[4],
- int UNUSED(fast), int (*setMaterial)(int, void *attribs))
+ float (*partial_redraw_planes)[4],
+ int UNUSED(fast), int (*setMaterial)(int, void *attribs))
{
(void) partial_redraw_planes;
(void) setMaterial;
@@ -3056,54 +3056,50 @@
int res;
result = CDDM_copy(dm);
- if (!CustomData_has_layer(&result->faceData, CD_RECAST))
- {
+ if (!CustomData_has_layer(&result->faceData, CD_RECAST)) {
int *sourceRecastData = (int*)CustomData_get_layer(&dm->faceData, CD_RECAST);
CustomData_add_layer_named(&result->faceData, CD_RECAST, CD_DUPLICATE,
sourceRecastData, maxFaces, "recastData");
}
recastData = (int*)CustomData_get_layer(&result->faceData, CD_RECAST);
+
+ /* note: This is not good design! - really should not be doing this */
result->drawFacesTex = navmesh_DM_drawFacesTex;
result->drawFacesSolid = navmesh_DM_drawFacesSolid;
- //process mesh
+ /* process mesh */
res = buildNavMeshDataByDerivedMesh(dm, &vertsPerPoly, &nverts, &verts, &ndtris, &dtris,
- &npolys, &dmeshes, &polys, &dtrisToPolysMap, &dtrisToTrisMap,
- &trisToFacesMap);
- if (res)
- {
+ &npolys, &dmeshes, &polys, &dtrisToPolysMap, &dtrisToTrisMap,
+ &trisToFacesMap);
+ if (res) {
size_t polyIdx;
- //invalidate concave polygon
- for (polyIdx=0; polyIdx<(size_t)npolys; polyIdx++)
- {
+ /* invalidate concave polygon */
+ for (polyIdx=0; polyIdx<(size_t)npolys; polyIdx++) {
unsigned short* poly = &polys[polyIdx*2*vertsPerPoly];
- if (!polyIsConvex(poly, vertsPerPoly, verts))
- {
- //set negative polygon idx to all faces
+ if (!polyIsConvex(poly, vertsPerPoly, verts)) {
+ /* set negative polygon idx to all faces */
unsigned short *dmesh = &dmeshes[4*polyIdx];
unsigned short tbase = dmesh[2];
unsigned short tnum = dmesh[3];
unsigned short ti;
- for (ti=0; ti<tnum; ti++)
- {
+ for (ti=0; ti<tnum; ti++) {
unsigned short triidx = dtrisToTrisMap[tbase+ti];
unsigned short faceidx = trisToFacesMap[triidx];
- if (recastData[faceidx]>0)
+ if (recastData[faceidx] > 0) {
recastData[faceidx] = -recastData[faceidx];
+ }
}
}
}
-
}
- else
- {
+ else {
printf("Error during creation polygon infos\n");
}
- //clean up
+ /* clean up */
if (verts!=NULL)
MEM_freeN(verts);
if (dtris!=NULL)
Modified: trunk/blender/source/blender/makesrna/intern/rna_object.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_object.c 2011-10-09 21:13:07 UTC (rev 40881)
+++ trunk/blender/source/blender/makesrna/intern/rna_object.c 2011-10-09 21:43:13 UTC (rev 40882)
@@ -890,6 +890,7 @@
static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
{
Object *ob= (Object*)ptr->id.data;
+ const int was_navmesh= (ob->gameflag & OB_NAVMESH);
ob->body_type= value;
switch (ob->body_type) {
@@ -906,8 +907,10 @@
ob->gameflag |= OB_NAVMESH;
ob->gameflag &= ~(OB_SENSOR|OB_COLLISION|OB_DYNAMIC|OB_OCCLUDER);
- /* could be moved into mesh UI but for now ensure mesh data layer */
- BKE_mesh_ensure_navmesh(ob->data);
+ if (ob->type == OB_MESH) {
+ /* could be moved into mesh UI but for now ensure mesh data layer */
+ BKE_mesh_ensure_navmesh(ob->data);
+ }
break;
case OB_BODY_TYPE_NO_COLLISION:
@@ -940,6 +943,14 @@
ob->bsoft = bsbNew();
break;
}
+
+ if (was_navmesh != (ob->gameflag & OB_NAVMESH)) {
+ if (ob->type == OB_MESH) {
+ DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
+ WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
+ }
+ }
+
}
static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
More information about the Bf-blender-cvs
mailing list