navmesh: solve bad level calls to edit mesh functions
Move navmesh operators from editors/object to editors/mesh
This commit is contained in:
@@ -380,8 +380,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
|
||||
col.prop(md, "mirror_object", text="")
|
||||
|
||||
def NAVMESH(self, layout, ob, md):
|
||||
layout.operator("object.assign_navpolygon")
|
||||
layout.operator("object.assign_new_navpolygon")
|
||||
layout.operator("mesh.assign_navpolygon")
|
||||
layout.operator("mesh.assign_new_navpolygon")
|
||||
|
||||
def MULTIRES(self, layout, ob, md):
|
||||
layout.row().prop(md, "subdivision_type", expand=True)
|
||||
|
@@ -412,7 +412,7 @@ class SCENE_PT_game_navmesh(SceneButtonsPanel, bpy.types.Panel):
|
||||
|
||||
rd = context.scene.game_settings.recast_data
|
||||
|
||||
layout.operator("object.create_navmesh", text='Build navigation mesh')
|
||||
layout.operator("mesh.create_navmesh", text='Build navigation mesh')
|
||||
|
||||
col = layout.column()
|
||||
col.label(text="Rasterization:")
|
||||
|
@@ -52,4 +52,16 @@ set(SRC
|
||||
mesh_intern.h
|
||||
)
|
||||
|
||||
if(WITH_GAMEENGINE)
|
||||
add_definitions(-DWITH_GAMEENGINE)
|
||||
|
||||
list(APPEND INC
|
||||
../../../../extern/recastnavigation
|
||||
)
|
||||
|
||||
list(APPEND SRC
|
||||
mesh_navmesh.c
|
||||
)
|
||||
endif()
|
||||
|
||||
blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}")
|
||||
|
@@ -15,4 +15,10 @@ if env['OURPLATFORM'] == 'linux':
|
||||
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
|
||||
incs += ' ' + env['BF_PTHREADS_INC']
|
||||
|
||||
if env['WITH_BF_GAMEENGINE']:
|
||||
incs += ' #/extern/recastnavigation'
|
||||
defs.append('WITH_GAMEENGINE')
|
||||
else:
|
||||
sources.remove('mesh_navmesh.c')
|
||||
|
||||
env.BlenderLib ( 'bf_editors_mesh', sources, Split(incs), [], libtype=['core'], priority=[45] )
|
||||
|
@@ -40,6 +40,7 @@
|
||||
struct bContext;
|
||||
struct wmOperatorType;
|
||||
struct wmOperator;
|
||||
struct ViewContext;
|
||||
|
||||
/* ******************** editface.c */
|
||||
|
||||
@@ -64,7 +65,7 @@ extern struct EditEdge *addedgelist(EditMesh *em, struct EditVert *v1, struct Ed
|
||||
extern struct EditFace *addfacelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditVert *v3, struct EditVert *v4, struct EditFace *example, struct EditFace *exampleEdges);
|
||||
extern struct EditEdge *findedgelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2);
|
||||
|
||||
void em_setup_viewcontext(struct bContext *C, ViewContext *vc);
|
||||
void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc);
|
||||
|
||||
void MESH_OT_separate(struct wmOperatorType *ot);
|
||||
|
||||
@@ -169,7 +170,7 @@ void MESH_OT_solidify(struct wmOperatorType *ot);
|
||||
void MESH_OT_select_nth(struct wmOperatorType *ot);
|
||||
|
||||
|
||||
extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
|
||||
extern EditEdge *findnearestedge(struct ViewContext *vc, int *dist);
|
||||
void editmesh_select_by_material(EditMesh *em, int index);
|
||||
void EM_recalc_normal_direction(EditMesh *em, int inside, int select); /* makes faces righthand turning */
|
||||
void EM_select_more(EditMesh *em);
|
||||
@@ -185,7 +186,7 @@ void faceloop_select(EditMesh *em, EditEdge *startedge, int select);
|
||||
* if 0, unselected vertice are given the bias
|
||||
* strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
|
||||
*/
|
||||
extern EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict);
|
||||
extern EditVert *findnearestvert(struct ViewContext *vc, int *dist, short sel, short strict);
|
||||
|
||||
|
||||
/* ******************* editmesh_tools.c */
|
||||
@@ -256,5 +257,10 @@ void MESH_OT_drop_named_image(struct wmOperatorType *ot);
|
||||
void MESH_OT_edgering_select(struct wmOperatorType *ot);
|
||||
void MESH_OT_loopcut(struct wmOperatorType *ot);
|
||||
|
||||
/* ******************* mesh_navmesh.c */
|
||||
void MESH_OT_create_navmesh(struct wmOperatorType *ot);
|
||||
void MESH_OT_assign_navpolygon(struct wmOperatorType *ot);
|
||||
void MESH_OT_assign_new_navpolygon(struct wmOperatorType *ot);
|
||||
|
||||
#endif // MESH_INTERN_H
|
||||
|
||||
|
@@ -54,21 +54,16 @@
|
||||
|
||||
#include "ED_object.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "mesh_intern.h"
|
||||
#include "recast-capi.h"
|
||||
|
||||
/*mesh/mesh_intern.h */
|
||||
extern struct EditVert *addvertlist(EditMesh *em, float *vec, struct EditVert *example);
|
||||
extern struct EditFace *addfacelist(EditMesh *em, struct EditVert *v1, struct EditVert *v2, struct EditVert *v3, struct EditVert *v4, struct EditFace *example, struct EditFace *exampleEdges);
|
||||
extern void free_vertlist(EditMesh *em, ListBase *edve);
|
||||
extern void free_edgelist(EditMesh *em, ListBase *lb);
|
||||
extern void free_facelist(EditMesh *em, ListBase *lb);
|
||||
|
||||
static void createVertsTrisData(bContext *C, LinkNode* obs, int *nverts_r, float **verts_r, int *ntris_r, int **tris_r)
|
||||
{
|
||||
MVert *mvert;
|
||||
@@ -108,8 +103,8 @@ static void createVertsTrisData(bContext *C, LinkNode* obs, int *nverts_r, float
|
||||
}
|
||||
|
||||
//create data
|
||||
verts = MEM_mallocN(sizeof(float)*3*nverts, "verts");
|
||||
tris = MEM_mallocN(sizeof(int)*3*ntris, "faces");
|
||||
verts = MEM_mallocN(sizeof(float)*3*nverts, "createVertsTrisData verts");
|
||||
tris = MEM_mallocN(sizeof(int)*3*ntris, "createVertsTrisData faces");
|
||||
|
||||
basenverts = 0;
|
||||
tri = tris;
|
||||
@@ -253,7 +248,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
|
||||
}
|
||||
|
||||
// Allocate array that can hold triangle flags.
|
||||
triflags = MEM_callocN(sizeof(unsigned char)*ntris, "triflags");
|
||||
triflags = MEM_callocN(sizeof(unsigned char)*ntris, "buildNavMesh triflags");
|
||||
|
||||
// Find triangles which are walkable based on their slope and rasterize them.
|
||||
recast_markWalkableTriangles(RAD2DEG(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);
|
||||
@@ -520,15 +515,18 @@ static int create_navmesh_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
buildNavMesh(&scene->gm.recastData, nverts, verts, ntris, tris, &pmesh, &dmesh);
|
||||
createRepresentation(C, pmesh, dmesh, navmeshBase);
|
||||
|
||||
MEM_freeN(verts);
|
||||
MEM_freeN(tris);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_create_navmesh(wmOperatorType *ot)
|
||||
void MESH_OT_create_navmesh(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Create navigation mesh";
|
||||
ot->description= "Create navigation mesh for selected objects";
|
||||
ot->idname= "OBJECT_OT_create_navmesh";
|
||||
ot->idname= "MESH_OT_create_navmesh";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= create_navmesh_exec;
|
||||
@@ -537,14 +535,6 @@ void OBJECT_OT_create_navmesh(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int assign_navpolygon_poll(bContext *C)
|
||||
{
|
||||
Object *ob= (Object *)CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
|
||||
if (!ob || !ob->data)
|
||||
return 0;
|
||||
return (((Mesh*)ob->data)->edit_mesh != NULL);
|
||||
}
|
||||
|
||||
static int assign_navpolygon_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
@@ -584,15 +574,15 @@ static int assign_navpolygon_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_assign_navpolygon(struct wmOperatorType *ot)
|
||||
void MESH_OT_assign_navpolygon(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Assign polygon index";
|
||||
ot->description= "Assign polygon index to face by active face";
|
||||
ot->idname= "OBJECT_OT_assign_navpolygon";
|
||||
ot->idname= "MESH_OT_assign_navpolygon";
|
||||
|
||||
/* api callbacks */
|
||||
ot->poll = assign_navpolygon_poll;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
ot->exec= assign_navpolygon_exec;
|
||||
|
||||
/* flags */
|
||||
@@ -668,15 +658,15 @@ static int assign_new_navpolygon_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_assign_new_navpolygon(struct wmOperatorType *ot)
|
||||
void MESH_OT_assign_new_navpolygon(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Assign new polygon index";
|
||||
ot->description= "Assign new polygon index to face";
|
||||
ot->idname= "OBJECT_OT_assign_new_navpolygon";
|
||||
ot->idname= "MESH_OT_assign_new_navpolygon";
|
||||
|
||||
/* api callbacks */
|
||||
ot->poll = assign_navpolygon_poll;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
ot->exec= assign_new_navpolygon_exec;
|
||||
|
||||
/* flags */
|
@@ -151,6 +151,12 @@ void ED_operatortypes_mesh(void)
|
||||
|
||||
WM_operatortype_append(MESH_OT_solidify);
|
||||
WM_operatortype_append(MESH_OT_select_nth);
|
||||
|
||||
#ifdef WITH_GAMEENGINE
|
||||
WM_operatortype_append(MESH_OT_create_navmesh);
|
||||
WM_operatortype_append(MESH_OT_assign_navpolygon);
|
||||
WM_operatortype_append(MESH_OT_assign_new_navpolygon);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0 /* UNUSED, remove? */
|
||||
|
@@ -58,16 +58,6 @@ set(SRC
|
||||
object_intern.h
|
||||
)
|
||||
|
||||
if(WITH_GAMEENGINE)
|
||||
list(APPEND INC
|
||||
../../../../extern/recastnavigation
|
||||
)
|
||||
|
||||
list(APPEND SRC
|
||||
object_navmesh.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_PYTHON)
|
||||
add_definitions(-DWITH_PYTHON)
|
||||
endif()
|
||||
|
@@ -225,10 +225,5 @@ void OBJECT_OT_group_remove(struct wmOperatorType *ot);
|
||||
/* object_bake.c */
|
||||
void OBJECT_OT_bake_image(wmOperatorType *ot);
|
||||
|
||||
/* object_navmesh.cpp */
|
||||
void OBJECT_OT_create_navmesh(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_assign_navpolygon(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_assign_new_navpolygon(struct wmOperatorType *ot);
|
||||
|
||||
#endif /* ED_OBJECT_INTERN_H */
|
||||
|
||||
|
@@ -214,12 +214,6 @@ void ED_operatortypes_object(void)
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_bake_image);
|
||||
WM_operatortype_append(OBJECT_OT_drop_named_material);
|
||||
|
||||
#ifdef WITH_GAMEENGINE
|
||||
WM_operatortype_append(OBJECT_OT_create_navmesh);
|
||||
WM_operatortype_append(OBJECT_OT_assign_navpolygon);
|
||||
WM_operatortype_append(OBJECT_OT_assign_new_navpolygon);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user