[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30597] branches/soc-2010-nicks: implemented navigation mesh visualization via modifier
Nick Samarin
nicks1987 at bigmir.net
Wed Jul 21 21:45:02 CEST 2010
Revision: 30597
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30597
Author: nicks
Date: 2010-07-21 21:44:59 +0200 (Wed, 21 Jul 2010)
Log Message:
-----------
implemented navigation mesh visualization via modifier
Modified Paths:
--------------
branches/soc-2010-nicks/release/scripts/ui/properties_data_modifier.py
branches/soc-2010-nicks/source/blender/blenkernel/BKE_DerivedMesh.h
branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp
branches/soc-2010-nicks/source/blender/makesdna/DNA_modifier_types.h
branches/soc-2010-nicks/source/blender/makesrna/intern/rna_modifier.c
branches/soc-2010-nicks/source/blender/modifiers/intern/MOD_navmesh.cpp
Modified: branches/soc-2010-nicks/release/scripts/ui/properties_data_modifier.py
===================================================================
--- branches/soc-2010-nicks/release/scripts/ui/properties_data_modifier.py 2010-07-21 19:44:06 UTC (rev 30596)
+++ branches/soc-2010-nicks/release/scripts/ui/properties_data_modifier.py 2010-07-21 19:44:59 UTC (rev 30597)
@@ -461,66 +461,8 @@
row.label()
def NAVMESH(self, layout, ob, md, wide_ui):
- layout.label(text="Rasterization:")
- split = layout.split()
+ layout = self.layout
- col = split.column()
- col.prop(md, "cellsize")
- if wide_ui:
- col = split.column()
- col.prop(md, "cellheight")
-
- layout.separator()
-
- layout.label(text="Agent:")
- split = layout.split()
- col = split.column()
- row = col.row()
- row.prop(md, "agentheight")
- row = col.row()
- row.prop(md, "agentradius")
- if wide_ui:
- col = split.column()
- row = col.row()
- row.prop(md, "agentmaxslope")
- row = col.row()
- row.prop(md, "agentmaxclimb")
-
- layout.separator()
-
- layout.label(text="Region:")
- split = layout.split()
- col = split.column()
- col.prop(md, "regionminsize")
- if wide_ui:
- col = split.column()
- col.prop(md, "regionmergesize")
-
- layout.separator()
-
- layout.label(text="Polygonization:")
- split = layout.split()
- col = split.column()
- row = col.row()
- row.prop(md, "edgemaxlen")
- row = col.row()
- row.prop(md, "edgemaxerror")
- if wide_ui:
- col = split.column()
- row = col.row()
- row.prop(md, "vertsperpoly")
-
- layout.separator()
-
- layout.label(text="Detail Mesh:")
- split = layout.split()
- col = split.column()
- col.prop(md, "detailsampledist")
- if wide_ui:
- col = split.column()
- col.prop(md, "detailsamplemaxerror")
-
-
def PARTICLE_INSTANCE(self, layout, ob, md, wide_ui):
layout.prop(md, "object")
layout.prop(md, "particle_system_number", text="Particle System")
Modified: branches/soc-2010-nicks/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2010-nicks/source/blender/blenkernel/BKE_DerivedMesh.h 2010-07-21 19:44:06 UTC (rev 30596)
+++ branches/soc-2010-nicks/source/blender/blenkernel/BKE_DerivedMesh.h 2010-07-21 19:44:59 UTC (rev 30597)
@@ -227,6 +227,7 @@
*
* Also called for *final* editmode DerivedMeshes
*/
+
void (*drawEdges)(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges);
/* Draw all loose edges (edges w/ no adjoining faces) */
Modified: branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp
===================================================================
--- branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp 2010-07-21 19:44:06 UTC (rev 30596)
+++ branches/soc-2010-nicks/source/blender/editors/object/object_navmesh.cpp 2010-07-21 19:44:59 UTC (rev 30597)
@@ -36,6 +36,7 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_ID.h"
#include "BKE_library.h"
@@ -306,6 +307,7 @@
int i,j, k, polyverts;
unsigned short* v;
int face[3];
+ Scene *scene= CTX_data_scene(C);
zero_v3(co);
zero_v3(rot);
@@ -392,6 +394,9 @@
obedit->gameflag |= OB_NAVMESH;
obedit->body_type = OB_BODY_TYPE_NAVMESH;
rename_id((ID *)obedit, "Navmesh");
+
+ ED_object_modifier_add(NULL, scene, obedit, NULL, eModifierType_NavMesh);
+ //ModifierData *md= modifiers_findByType(ob, eModifierType_NavMesh);
return obedit;
}
Modified: branches/soc-2010-nicks/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- branches/soc-2010-nicks/source/blender/makesdna/DNA_modifier_types.h 2010-07-21 19:44:06 UTC (rev 30596)
+++ branches/soc-2010-nicks/source/blender/makesdna/DNA_modifier_types.h 2010-07-21 19:44:59 UTC (rev 30597)
@@ -727,21 +727,7 @@
typedef struct NavMeshModifierData {
ModifierData modifier;
- char pad[4];
- float cellsize;
- float cellheight;
- float agentmaxslope;
- float agentmaxclimb;
- float agentheight;
- float agentradius;
- float edgemaxlen;
- float edgemaxerror;
- float regionminsize;
- float regionmergesize;
- int vertsperpoly;
- float detailsampledist;
- float detailsamplemaxerror;
-
+
} NavMeshModifierData;
#endif
Modified: branches/soc-2010-nicks/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- branches/soc-2010-nicks/source/blender/makesrna/intern/rna_modifier.c 2010-07-21 19:44:06 UTC (rev 30596)
+++ branches/soc-2010-nicks/source/blender/makesrna/intern/rna_modifier.c 2010-07-21 19:44:59 UTC (rev 30597)
@@ -2219,72 +2219,6 @@
RNA_def_struct_sdna(srna, "NavMeshModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_DECIM);
- prop= RNA_def_property(srna, "cellsize", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.1, 1, 0.01, 2);
- RNA_def_property_ui_text(prop, "Cell size", "Rasterized cell size");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "cellheight", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.1, 1, 0.01, 2);
- RNA_def_property_ui_text(prop, "Cell height", "Rasterized cell height");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "agentheight", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.1, 5, 0.1, 2);
- RNA_def_property_ui_text(prop, "Agent height", "Minimum height where the agent can still walk");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "agentradius", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.1, 5, 0.1, 2);
- RNA_def_property_ui_text(prop, "Agent radius", "Radius of the agent");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "agentmaxclimb", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.1, 5, 0.1, 2);
- RNA_def_property_ui_text(prop, "Max climb", "Maximum height between grid cells the agent can climb");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "agentmaxslope", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_ui_range(prop, 0, 90, 1, 2);
- RNA_def_property_ui_text(prop, "Max slope", "Maximum walkable slope angle in degrees");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
-
- prop= RNA_def_property(srna, "regionminsize", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 150, 1, 2);
- RNA_def_property_ui_text(prop, "Min region size", "Minimum regions size. Smaller regions will be deleted");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "regionmergesize", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 150, 1, 2);
- RNA_def_property_ui_text(prop, "Merged region size", "Minimum regions size. Smaller regions will be merged");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "edgemaxlen", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0, 50, 1, 2);
- RNA_def_property_ui_text(prop, "Max edge length", "Maximum contour edge length");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "edgemaxerror", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.1, 3.0, 0.1, 2);
- RNA_def_property_ui_text(prop, "Max edge error", "Maximum distance error from contour to cells");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "vertsperpoly", PROP_INT, PROP_NONE);
- RNA_def_property_ui_range(prop, 3, 12, 1, 0);
- RNA_def_property_ui_text(prop, "Verts per poly", "Max number of vertices per polygon");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "detailsampledist", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.0, 16.0, 1, 2);
- RNA_def_property_ui_text(prop, "Sample Distance", "Detail mesh sample spacing");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
- prop= RNA_def_property(srna, "detailsamplemaxerror", PROP_FLOAT, PROP_NONE);
- RNA_def_property_ui_range(prop, 0.0, 16.0, 1, 2);
- RNA_def_property_ui_text(prop, "Max Sample Error", "Detail mesh simplification max sample error");
- RNA_def_property_update(prop, 0, "rna_Modifier_update");
-
}
void RNA_def_modifier(BlenderRNA *brna)
Modified: branches/soc-2010-nicks/source/blender/modifiers/intern/MOD_navmesh.cpp
===================================================================
--- branches/soc-2010-nicks/source/blender/modifiers/intern/MOD_navmesh.cpp 2010-07-21 19:44:06 UTC (rev 30596)
+++ branches/soc-2010-nicks/source/blender/modifiers/intern/MOD_navmesh.cpp 2010-07-21 19:44:59 UTC (rev 30597)
@@ -46,20 +46,6 @@
static void initData(ModifierData *md)
{
NavMeshModifierData *nmmd = (NavMeshModifierData*) md;
-
- nmmd->cellsize = 0.3f;
- nmmd->cellheight = 0.2f;
- nmmd->agentmaxslope = 45.0f;
- nmmd->agentmaxclimb = 0.9f;
- nmmd->agentheight = 2.0f;
- nmmd->agentradius = 0.6f;
- nmmd->edgemaxlen = 12.0f;
- nmmd->edgemaxerror = 1.3f;
- nmmd->regionminsize = 50.f;
- nmmd->regionmergesize = 20.f;
- nmmd->vertsperpoly = 6;
- nmmd->detailsampledist = 6.0f;
- nmmd->detailsamplemaxerror = 1.0f;
}
static void copyData(ModifierData *md, ModifierData *target)
@@ -70,228 +56,11 @@
//.todo - deep copy
}
-static DerivedMesh *buildNavMesh(NavMeshModifierData *mmd,DerivedMesh *dm)
-{
- const int nverts = dm->getNumVerts(dm);
- MVert *mvert = dm->getVertArray(dm);
- const int nfaces = dm->getNumFaces(dm);
- MFace *mface = dm->getFaceArray(dm);
- float* verts;
- int *tris, *tri;
- float bmin[3], bmax[3];
- int i,j;
- DerivedMesh* result = NULL;
- rcHeightfield* solid;
- unsigned char *triflags;
- rcCompactHeightfield* chf;
- rcContourSet *cset;
- rcPolyMesh* pmesh;
- rcPolyMeshDetail* dmesh;
- int numVerts, numEdges, numFaces;
-
- //calculate count of tris
- int ntris = nfaces;
- for (i=0; i<nfaces; i++)
- {
- MFace* mf = &mface[i];
- if (mf->v4)
- ntris+=1;
- }
-
- //create verts
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list