Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-09-28 11:34:48 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-28 11:34:48 +0400
commit4a157de23d43c22abec8bd6922f0355334e413f8 (patch)
treec8ca75fef261ce1316ea9042aa4bd689aa4eb584 /source/blender/editors
parentdbdb58f2a3c0d086afabdacab40c4d83c79e1a04 (diff)
parentbc593cac2354c863f074d9d51cffb3dca9f499a3 (diff)
svn merge ^/trunk/blender -r40587:40643
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/curve/editcurve.c10
-rw-r--r--source/blender/editors/interface/interface.c3
-rw-r--r--source/blender/editors/interface/interface_handlers.c4
-rw-r--r--source/blender/editors/interface/interface_icons.c16
-rw-r--r--source/blender/editors/interface/interface_regions.c22
-rw-r--r--source/blender/editors/interface/interface_style.c3
-rw-r--r--source/blender/editors/interface/interface_templates.c2
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt12
-rw-r--r--source/blender/editors/mesh/SConscript10
-rw-r--r--source/blender/editors/mesh/mesh_navmesh.c597
-rw-r--r--source/blender/editors/mesh/mesh_ops.c6
-rw-r--r--source/blender/editors/object/CMakeLists.txt10
-rw-r--r--source/blender/editors/object/SConscript4
-rw-r--r--source/blender/editors/object/object_bake.c3
-rw-r--r--source/blender/editors/object/object_intern.h5
-rw-r--r--source/blender/editors/object/object_navmesh.cpp628
-rw-r--r--source/blender/editors/object/object_ops.c6
-rw-r--r--source/blender/editors/object/object_vgroup.c24
-rw-r--r--source/blender/editors/physics/physics_fluid.c48
-rw-r--r--source/blender/editors/screen/glutil.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c9
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c2
-rw-r--r--source/blender/editors/space_file/filelist.c3
-rw-r--r--source/blender/editors/space_logic/logic_window.c1
-rw-r--r--source/blender/editors/space_node/node_edit.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c3
-rw-r--r--source/blender/editors/space_view3d/drawobject.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_buttons.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c4
-rw-r--r--source/blender/editors/transform/transform_generics.c3
-rw-r--r--source/blender/editors/transform/transform_input.c12
-rw-r--r--source/blender/editors/transform/transform_snap.c9
33 files changed, 755 insertions, 725 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 8c0424bd583..a52f181a0c9 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -6537,8 +6537,8 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
return nu;
}
-static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) {
-
+static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
+{
Object *obedit= CTX_data_edit_object(C);
ListBase *editnurb;
Nurb *nu;
@@ -6607,11 +6607,13 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf)
return OPERATOR_FINISHED;
}
-static int curve_prim_add(bContext *C, wmOperator *op, int type) {
+static int curve_prim_add(bContext *C, wmOperator *op, int type)
+{
return curvesurf_prim_add(C, op, type, 0);
}
-static int surf_prim_add(bContext *C, wmOperator *op, int type) {
+static int surf_prim_add(bContext *C, wmOperator *op, int type)
+{
return curvesurf_prim_add(C, op, type, 1);
}
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index aad67b6b0be..286906402b9 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2804,7 +2804,8 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, i
* otherwise return -1.
* (1<<findBitIndex(x))==x for powers of two.
*/
-static int findBitIndex(unsigned int x) {
+static int findBitIndex(unsigned int x)
+{
if (!x || (x&(x-1))!=0) { /* x&(x-1) strips lowest bit */
return -1;
} else {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 568eaf358e5..082ddb5b060 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1684,7 +1684,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
/* not a file?, strip non utf-8 chars */
if(strip) {
/* wont happen often so isnt that annoying to keep it here for a while */
- printf("invalid utf8 - stripped chars %d\n", strip);
+ printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip);
}
}
@@ -5914,7 +5914,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE);
}
else {
- printf("Error, but->menu_key type: %d\n", but->type);
+ printf("%s: error, but->menu_key type: %d\n", __func__, but->type);
}
break;
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index c3a0f438fbe..fbad34252e7 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -752,7 +752,7 @@ int UI_icon_get_width(int icon_id)
if (icon==NULL) {
if (G.f & G_DEBUG)
- printf("UI_icon_get_width: Internal error, no icon for icon ID: %d\n", icon_id);
+ printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return 0;
}
@@ -777,7 +777,7 @@ int UI_icon_get_height(int icon_id)
if (icon==NULL) {
if (G.f & G_DEBUG)
- printf("UI_icon_get_height: Internal error, no icon for icon ID: %d\n", icon_id);
+ printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return 0;
}
@@ -825,7 +825,7 @@ static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size)
if (!prv_img) {
if (G.f & G_DEBUG)
- printf("Error: requested preview image does not exist");
+ printf("%s, error: requested preview image does not exist", __func__);
}
if (!prv_img->rect[size]) {
prv_img->w[size] = render_size;
@@ -842,7 +842,7 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIco
{
if (!prv_img) {
if (G.f & G_DEBUG)
- printf("No preview image for this ID: %s\n", id->name);
+ printf("%s: no preview image for this ID: %s\n", __func__, id->name);
return;
}
@@ -858,7 +858,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
/* sanity check */
if(w<=0 || h<=0 || w>2000 || h>2000) {
- printf("icon_draw_rect: icons are %i x %i pixels?\n", w, h);
+ printf("%s: icons are %i x %i pixels?\n", __func__, w, h);
BLI_assert(!"invalid icon size");
return;
}
@@ -948,19 +948,19 @@ static int get_draw_size(enum eIconSizes size)
return 0;
}
-static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), int is_preview)
+static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), short is_preview)
{
Icon *icon = NULL;
DrawInfo *di = NULL;
IconImage *iimg;
- float fdraw_size= UI_DPI_ICON_FAC*draw_size;
+ float fdraw_size= is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC);
int w, h;
icon = BKE_icon_get(icon_id);
if (icon==NULL) {
if (G.f & G_DEBUG)
- printf("icon_draw_mipmap: Internal error, no icon for icon ID: %d\n", icon_id);
+ printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return;
}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 4a9eb8113fe..c898ba983c7 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -174,7 +174,7 @@ static MenuData *decompose_menu_string(const char *str)
*s= '\0';
s++;
} else if (s[1]=='t') {
- nitem_is_title= 1;
+ nitem_is_title= (s != instr); /* check for empty title */
*s= '\0';
s++;
@@ -213,11 +213,13 @@ static MenuData *decompose_menu_string(const char *str)
nicon= 0;
}
- if (c=='\0')
+ if (c=='\0') {
break;
- } else if (!nitem)
+ }
+ } else if (!nitem) {
nitem= s;
-
+ }
+
s++;
}
@@ -233,6 +235,7 @@ void ui_set_name_menu(uiBut *but, int value)
for (i=0; i<md->nitems; i++) {
if (md->items[i].retval==value) {
BLI_strncpy(but->drawstr, md->items[i].str, sizeof(but->drawstr));
+ break;
}
}
@@ -1647,11 +1650,12 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
}
/* inconsistent, but menus with labels do not look good flipped */
- for(a=0, b=0; a<md->nitems; a++, b++) {
- entry= &md->items[a];
-
- if(entry->sepr && entry->str[0])
+ entry= md->items;
+ for(a=0; a<md->nitems; a++, entry++) {
+ if(entry->sepr && entry->str[0]) {
block->flag |= UI_BLOCK_NO_FLIP;
+ break;
+ }
}
/* create items */
@@ -2555,7 +2559,7 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
MenuType *mt= WM_menutype_find(idname, TRUE);
if(mt==NULL) {
- printf("uiPupMenuInvoke: named menu \"%s\" not found\n", idname);
+ printf("%s: named menu \"%s\" not found\n", __func__, idname);
return;
}
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 3009d4fea09..92d02ff3dc2 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -42,6 +42,7 @@
#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BLI_string.h"
+#include "BLI_utildefines.h"
#include "BKE_global.h"
@@ -357,7 +358,7 @@ void uiStyleInit(void)
if (font->blf_id == -1) {
if (G.f & G_DEBUG)
- printf("uiStyleInit error, no fonts available\n");
+ printf("%s: error, no fonts available\n", __func__);
}
else {
/* ? just for speed to initialize?
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index a4622f50725..44aa6d1e090 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1040,7 +1040,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
/* enabled */
uiBlockSetEmboss(block, UI_EMBOSSN);
- uiItemR(row, &ptr, "mute", 0, "", (con->flag & CONSTRAINT_OFF) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF);
+ uiItemR(row, &ptr, "mute", 0, "", (con->flag & CONSTRAINT_OFF) ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF);
uiBlockSetEmboss(block, UI_EMBOSS);
uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT);
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index aff5f69e9d5..93fca6fe52b 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -56,4 +56,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}")
diff --git a/source/blender/editors/mesh/SConscript b/source/blender/editors/mesh/SConscript
index 88df192c2fa..8142faf67a1 100644
--- a/source/blender/editors/mesh/SConscript
+++ b/source/blender/editors/mesh/SConscript
@@ -3,6 +3,8 @@ Import ('env')
sources = env.Glob('*.c')
+defs = []
+
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' ../../gpu ../../blenloader'
@@ -16,4 +18,10 @@ if env['OURPLATFORM'] == 'linux':
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
incs += ' ' + env['BF_PTHREADS_INC']
-env.BlenderLib ( 'bf_editors_mesh', sources, Split(incs), [], libtype=['core'], priority=[45] )
+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), defs, libtype=['core'], priority=[45] )
diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c
new file mode 100644
index 00000000000..1cd5dcdb241
--- /dev/null
+++ b/source/blender/editors/mesh/mesh_navmesh.c
@@ -0,0 +1,597 @@
+/**
+* $Id$
+*
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* The Original Code is Copyright (C) 2011 by Blender Foundation
+* All rights reserved.
+*
+* The Original Code is: all of this file.
+*
+* Contributor(s): Benoit Bolsee,
+* Nick Samarin
+*
+* ***** END GPL LICENSE BLOCK *****
+*/
+
+#include <math.h>
+
+#include "MEM_guardedalloc.h"
+
+#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"
+#include "BKE_depsgraph.h"
+#include "BKE_context.h"
+#include "BKE_main.h"
+#include "BKE_mesh.h"
+#include "BKE_modifier.h"
+#include "BKE_scene.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_cdderivedmesh.h"
+
+#include "BLI_editVert.h"
+#include "BLI_listbase.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
+
+#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"
+
+static void createVertsTrisData(bContext *C, LinkNode* obs, int *nverts_r, float **verts_r, int *ntris_r, int **tris_r)
+{
+ MVert *mvert;
+ int nfaces= 0, *tri, i, curnverts, basenverts, curnfaces;
+ MFace *mface;
+ float co[3], wco[3];
+ Object *ob;
+ LinkNode *oblink, *dmlink;
+ DerivedMesh *dm;
+ Scene* scene= CTX_data_scene(C);
+ LinkNode* dms= NULL;
+
+ int nverts, ntris, *tris;
+ float *verts;
+
+ nverts= 0;
+ ntris= 0;
+
+ /* calculate number of verts and tris */
+ for(oblink= obs; oblink; oblink= oblink->next) {
+ ob= (Object*) oblink->link;
+ dm= mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH);
+ BLI_linklist_append(&dms, (void*)dm);
+
+ nverts+= dm->getNumVerts(dm);
+ nfaces= dm->getNumFaces(dm);
+ ntris+= nfaces;
+
+ /* resolve quad faces */
+ mface= dm->getFaceArray(dm);
+ for(i= 0; i<nfaces; i++) {
+ MFace* mf= &mface[i];
+ if(mf->v4)
+ ntris+=1;
+ }
+ }
+
+ /* create data */
+ verts= MEM_mallocN(sizeof(float)*3*nverts, "createVertsTrisData verts");
+ tris= MEM_mallocN(sizeof(int)*3*ntris, "createVertsTrisData faces");
+
+ basenverts= 0;
+ tri= tris;
+ for(oblink= obs, dmlink= dms; oblink && dmlink;
+ oblink= oblink->next, dmlink= dmlink->next) {
+ ob= (Object*) oblink->link;
+ dm= (DerivedMesh*) dmlink->link;
+
+ curnverts= dm->getNumVerts(dm);
+ mvert= dm->getVertArray(dm);
+
+ /* copy verts */
+ for(i= 0; i<curnverts; i++) {
+ MVert *v= &mvert[i];
+
+ copy_v3_v3(co, v->co);
+ mul_v3_m4v3(wco, ob->obmat, co);
+
+ verts[3*(basenverts+i)+0]= wco[0];
+ verts[3*(basenverts+i)+1]= wco[2];
+ verts[3*(basenverts+i)+2]= wco[1];
+ }
+
+ /* create tris */
+ curnfaces= dm->getNumFaces(dm);
+ mface= dm->getFaceArray(dm);
+
+ for(i= 0; i<curnfaces; i++) {
+ MFace* mf= &mface[i];
+
+ tri[0]= basenverts + mf->v1;
+ tri[1]= basenverts + mf->v3;
+ tri[2]= basenverts + mf->v2;
+ tri += 3;
+
+ if(mf->v4) {
+ tri[0]= basenverts + mf->v1;
+ tri[1]= basenverts + mf->v4;
+ tri[2]= basenverts + mf->v3;
+ tri += 3;
+ }
+ }
+
+ basenverts+= curnverts;
+ }
+
+ /* release derived mesh */
+ for(dmlink= dms; dmlink; dmlink= dmlink->next) {
+ dm= (DerivedMesh*) dmlink->link;
+ dm->release(dm);
+ }
+
+ BLI_linklist_free(dms, NULL);
+
+ *nverts_r= nverts;
+ *verts_r= verts;
+ *ntris_r= ntris;
+ *tris_r= tris;
+}
+
+static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris,
+ struct recast_polyMesh **pmesh, struct recast_polyMeshDetail **dmesh)
+{
+ float bmin[3], bmax[3];
+ struct recast_heightfield *solid;
+ unsigned char *triflags;
+ struct recast_compactHeightfield* chf;
+ struct recast_contourSet *cset;
+ int width, height, walkableHeight, walkableClimb, walkableRadius;
+ int minRegionSize, mergeRegionSize, maxEdgeLen;
+ float detailSampleDist, detailSampleMaxError;
+
+ recast_calcBounds(verts, nverts, bmin, bmax);
+
+ /* ** Step 1. Initialize build config ** */
+ walkableHeight= (int)ceilf(recastParams->agentheight/ recastParams->cellheight);
+ walkableClimb= (int)floorf(recastParams->agentmaxclimb / recastParams->cellheight);
+ walkableRadius= (int)ceilf(recastParams->agentradius / recastParams->cellsize);
+ minRegionSize= (int)(recastParams->regionminsize * recastParams->regionminsize);
+ mergeRegionSize= (int)(recastParams->regionmergesize * recastParams->regionmergesize);
+ maxEdgeLen= (int)(recastParams->edgemaxlen/recastParams->cellsize);
+ detailSampleDist= recastParams->detailsampledist< 0.9f ? 0 :
+ recastParams->cellsize * recastParams->detailsampledist;
+ detailSampleMaxError= recastParams->cellheight * recastParams->detailsamplemaxerror;
+
+ /* Set the area where the navigation will be build. */
+ recast_calcGridSize(bmin, bmax, recastParams->cellsize, &width, &height);
+
+ /* ** Step 2: Rasterize input polygon soup ** */
+ /* Allocate voxel heightfield where we rasterize our input data to */
+ solid= recast_newHeightfield();
+
+ if(!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) {
+ recast_destroyHeightfield(solid);
+
+ return 0;
+ }
+
+ /* Allocate array that can hold triangle flags */
+ 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);
+ recast_rasterizeTriangles(verts, nverts, tris, triflags, ntris, solid);
+ MEM_freeN(triflags);
+
+ /* ** Step 3: Filter walkables surfaces ** */
+ recast_filterLedgeSpans(walkableHeight, walkableClimb, solid);
+ recast_filterWalkableLowHeightSpans(walkableHeight, solid);
+
+ /* ** Step 4: Partition walkable surface to simple regions ** */
+
+ chf= recast_newCompactHeightfield();
+ if(!recast_buildCompactHeightfield(walkableHeight, walkableClimb, RECAST_WALKABLE, solid, chf)) {
+ recast_destroyHeightfield(solid);
+ recast_destroyCompactHeightfield(chf);
+
+ return 0;
+ }
+
+ recast_destroyHeightfield(solid);
+
+ /* Prepare for region partitioning, by calculating distance field along the walkable surface */
+ if(!recast_buildDistanceField(chf)) {
+ recast_destroyCompactHeightfield(chf);
+
+ return 0;
+ }
+
+ /* Partition the walkable surface into simple regions without holes */
+ if(!recast_buildRegions(chf, walkableRadius, 0, minRegionSize, mergeRegionSize)) {
+ recast_destroyCompactHeightfield(chf);
+
+ return 0;
+ }
+
+ /* ** Step 5: Trace and simplify region contours ** */
+ /* Create contours */
+ cset= recast_newContourSet();
+
+ if(!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset)) {
+ recast_destroyCompactHeightfield(chf);
+ recast_destroyContourSet(cset);
+
+ return 0;
+ }
+
+ /* ** Step 6: Build polygons mesh from contours ** */
+ *pmesh= recast_newPolyMesh();
+ if(!recast_buildPolyMesh(cset, recastParams->vertsperpoly, *pmesh)) {
+ recast_destroyCompactHeightfield(chf);
+ recast_destroyContourSet(cset);
+ recast_destroyPolyMesh(*pmesh);
+
+ return 0;
+ }
+
+
+ /* ** Step 7: Create detail mesh which allows to access approximate height on each polygon ** */
+
+ *dmesh= recast_newPolyMeshDetail();
+ if(!recast_buildPolyMeshDetail(*pmesh, chf, detailSampleDist, detailSampleMaxError, *dmesh)) {
+ recast_destroyCompactHeightfield(chf);
+ recast_destroyContourSet(cset);
+ recast_destroyPolyMesh(*pmesh);
+ recast_destroyPolyMeshDetail(*dmesh);
+
+ return 0;
+ }
+
+ recast_destroyCompactHeightfield(chf);
+ recast_destroyContourSet(cset);
+
+ return 1;
+}
+
+static Object* createRepresentation(bContext *C, struct recast_polyMesh *pmesh, struct recast_polyMeshDetail *dmesh, Base* base)
+{
+ float co[3], rot[3];
+ EditMesh *em;
+ int i,j, k;
+ unsigned short* v;
+ int face[3];
+ Main *bmain= CTX_data_main(C);
+ Scene *scene= CTX_data_scene(C);
+ Object* obedit;
+ int createob= base==NULL;
+ int nverts, nmeshes, nvp;
+ unsigned short *verts, *meshes, *polys;
+ float bmin[3], cs, ch, *dverts;
+ unsigned char *tris;
+ ModifierData *md;
+
+ zero_v3(co);
+ zero_v3(rot);
+
+ if(createob) {
+ /* create new object */
+ obedit= ED_object_add_type(C, OB_MESH, co, rot, FALSE, 1);
+ }
+ else {
+ obedit= base->object;
+ scene_select_base(scene, base);
+ copy_v3_v3(obedit->loc, co);
+ copy_v3_v3(obedit->rot, rot);
+ }
+
+ ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER);
+ em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
+
+ if(!createob) {
+ /* clear */
+ if(em->verts.first) free_vertlist(em, &em->verts);
+ if(em->edges.first) free_edgelist(em, &em->edges);
+ if(em->faces.first) free_facelist(em, &em->faces);
+ if(em->selected.first) BLI_freelistN(&(em->selected));
+ }
+
+ /* create verts for polygon mesh */
+ verts= recast_polyMeshGetVerts(pmesh, &nverts);
+ recast_polyMeshGetBoundbox(pmesh, bmin, NULL);
+ recast_polyMeshGetCell(pmesh, &cs, &ch);
+
+ for(i= 0; i<nverts; i++) {
+ v= &verts[3*i];
+ co[0]= bmin[0] + v[0]*cs;
+ co[1]= bmin[1] + v[1]*ch;
+ co[2]= bmin[2] + v[2]*cs;
+ SWAP(float, co[1], co[2]);
+ addvertlist(em, co, NULL);
+ }
+
+ /* create custom data layer to save polygon idx */
+ CustomData_add_layer_named(&em->fdata, CD_RECAST, CD_CALLOC, NULL, 0, "createRepresentation recastData");
+
+ /* create verts and faces for detailed mesh */
+ meshes= recast_polyMeshDetailGetMeshes(dmesh, &nmeshes);
+ polys= recast_polyMeshGetPolys(pmesh, NULL, &nvp);
+ dverts= recast_polyMeshDetailGetVerts(dmesh, NULL);
+ tris= recast_polyMeshDetailGetTris(dmesh, NULL);
+
+ for(i= 0; i<nmeshes; i++) {
+ int uniquevbase= em->totvert;
+ unsigned short vbase= meshes[4*i+0];
+ unsigned short ndv= meshes[4*i+1];
+ unsigned short tribase= meshes[4*i+2];
+ unsigned short trinum= meshes[4*i+3];
+ const unsigned short* p= &polys[i*nvp*2];
+ int nv= 0;
+
+ for(j= 0; j < nvp; ++j) {
+ if(p[j]==0xffff) break;
+ nv++;
+ }
+
+ /* create unique verts */
+ for(j= nv; j<ndv; j++) {
+ copy_v3_v3(co, &dverts[3*(vbase + j)]);
+ SWAP(float, co[1], co[2]);
+ addvertlist(em, co, NULL);
+ }
+
+ EM_init_index_arrays(em, 1, 0, 0);
+
+ /* create faces */
+ for(j= 0; j<trinum; j++) {
+ unsigned char* tri= &tris[4*(tribase+j)];
+ EditFace* newFace;
+ int* polygonIdx;
+
+ for(k= 0; k<3; k++) {
+ if(tri[k]<nv)
+ face[k]= p[tri[k]]; /* shared vertex */
+ else
+ face[k]= uniquevbase+tri[k]-nv; /* unique vertex */
+ }
+ newFace= addfacelist(em, EM_get_vert_for_index(face[0]), EM_get_vert_for_index(face[2]),
+ EM_get_vert_for_index(face[1]), NULL, NULL, NULL);
+
+ /* set navigation polygon idx to the custom layer */
+ polygonIdx= (int*)CustomData_em_get(&em->fdata, newFace->data, CD_RECAST);
+ *polygonIdx= i+1; /* add 1 to avoid zero idx */
+ }
+
+ EM_free_index_arrays();
+ }
+
+ recast_destroyPolyMesh(pmesh);
+ recast_destroyPolyMeshDetail(dmesh);
+
+ BKE_mesh_end_editmesh((Mesh*)obedit->data, em);
+
+ DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+
+
+ ED_object_exit_editmode(C, EM_FREEDATA);
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
+
+ if(createob) {
+ obedit->gameflag&= ~OB_COLLISION;
+ obedit->gameflag|= OB_NAVMESH;
+ obedit->body_type= OB_BODY_TYPE_NAVMESH;
+ rename_id((ID *)obedit, "Navmesh");
+ }
+
+ md= modifiers_findByType(obedit, eModifierType_NavMesh);
+ if(!md) {
+ ED_object_modifier_add(NULL, bmain, scene, obedit, NULL, eModifierType_NavMesh);
+ }
+
+ return obedit;
+}
+
+static int create_navmesh_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Scene* scene= CTX_data_scene(C);
+ int nverts= 0, ntris= 0;
+ float *verts= NULL;
+ int *tris= 0;
+ struct recast_polyMesh *pmesh= NULL;
+ struct recast_polyMeshDetail *dmesh= NULL;
+ LinkNode* obs= NULL;
+ Base* navmeshBase= NULL;
+
+ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
+ if(base->object->body_type==OB_BODY_TYPE_NAVMESH) {
+ if(!navmeshBase || base==CTX_data_active_base(C))
+ navmeshBase= base;
+ }
+ else
+ BLI_linklist_append(&obs, (void*)base->object);
+ }
+ CTX_DATA_END;
+
+ createVertsTrisData(C, obs, &nverts, &verts, &ntris, &tris);
+ BLI_linklist_free(obs, NULL);
+ 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 MESH_OT_create_navmesh(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Create navigation mesh";
+ ot->description= "Create navigation mesh for selected objects";
+ ot->idname= "MESH_OT_create_navmesh";
+
+ /* api callbacks */
+ ot->exec= create_navmesh_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int assign_navpolygon_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *obedit= CTX_data_edit_object(C);
+ EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+
+ /* do work here */
+ int targetPolyIdx= -1;
+ EditFace *ef, *efa;
+ efa= EM_get_actFace(em, 0);
+
+ if(efa) {
+ if(CustomData_has_layer(&em->fdata, CD_RECAST)) {
+ targetPolyIdx= *(int*)CustomData_em_get(&em->fdata, efa->data, CD_RECAST);
+ targetPolyIdx= targetPolyIdx>=0? targetPolyIdx : -targetPolyIdx;
+
+ if(targetPolyIdx>0) {
+ /* set target poly idx to other selected faces */
+ ef= (EditFace*)em->faces.last;
+ while(ef) {
+ if((ef->f & SELECT )&& ef!=efa) {
+ int* recastDataBlock= (int*)CustomData_em_get(&em->fdata, ef->data, CD_RECAST);
+ *recastDataBlock= targetPolyIdx;
+ }
+ ef= ef->prev;
+ }
+ }
+ }
+ }
+
+ DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+
+ BKE_mesh_end_editmesh((Mesh*)obedit->data, em);
+
+ return OPERATOR_FINISHED;
+}
+
+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= "MESH_OT_assign_navpolygon";
+
+ /* api callbacks */
+ ot->poll= ED_operator_editmesh;
+ ot->exec= assign_navpolygon_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int compare(const void * a, const void * b){
+ return ( *(int*)a - *(int*)b );
+}
+
+static int findFreeNavPolyIndex(EditMesh* em)
+{
+ /* construct vector of indices */
+ int numfaces= em->totface;
+ int* indices= MEM_callocN(sizeof(int)*numfaces, "findFreeNavPolyIndex(indices)");
+ EditFace* ef= (EditFace*)em->faces.last;
+ int i, idx= 0, freeIdx= 1;
+
+ while(ef) {
+ int polyIdx= *(int*)CustomData_em_get(&em->fdata, ef->data, CD_RECAST);
+ indices[idx]= polyIdx;
+ idx++;
+ ef= ef->prev;
+ }
+
+ qsort(indices, numfaces, sizeof(int), compare);
+
+ /* search first free index */
+ freeIdx= 1;
+ for(i= 0; i<numfaces; i++) {
+ if(indices[i]==freeIdx)
+ freeIdx++;
+ else if(indices[i]>freeIdx)
+ break;
+ }
+
+ MEM_freeN(indices);
+
+ return freeIdx;
+}
+
+static int assign_new_navpolygon_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *obedit= CTX_data_edit_object(C);
+ EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+ EditFace *ef;
+
+ if(CustomData_has_layer(&em->fdata, CD_RECAST)) {
+ int targetPolyIdx= findFreeNavPolyIndex(em);
+
+ if(targetPolyIdx>0) {
+ /* set target poly idx to selected faces */
+ ef= (EditFace*)em->faces.last;
+ while(ef) {
+ if(ef->f & SELECT) {
+ int *recastDataBlock= (int*)CustomData_em_get(&em->fdata, ef->data, CD_RECAST);
+ *recastDataBlock= targetPolyIdx;
+ }
+ ef= ef->prev;
+ }
+ }
+ }
+
+ DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
+ WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
+
+ BKE_mesh_end_editmesh((Mesh*)obedit->data, em);
+ return OPERATOR_FINISHED;
+}
+
+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= "MESH_OT_assign_new_navpolygon";
+
+ /* api callbacks */
+ ot->poll= ED_operator_editmesh;
+ ot->exec= assign_new_navpolygon_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index c0e0714c43e..d7a93283640 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -162,6 +162,12 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(EXPORT_MESH_OT_wavefront);
WM_operatortype_append(MESH_OT_bridge_edge_loops);
+
+#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? */
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt
index 4cf1955ce93..081b0f1feaf 100644
--- a/source/blender/editors/object/CMakeLists.txt
+++ b/source/blender/editors/object/CMakeLists.txt
@@ -59,16 +59,6 @@ set(SRC
object_intern.h
)
-if(WITH_GAMEENGINE)
- list(APPEND INC
- ../../../../extern/recastnavigation/Recast/Include
- )
-
- list(APPEND SRC
- object_navmesh.cpp
- )
-endif()
-
if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
diff --git a/source/blender/editors/object/SConscript b/source/blender/editors/object/SConscript
index 4607cc4b1bf..883d0ca20ae 100644
--- a/source/blender/editors/object/SConscript
+++ b/source/blender/editors/object/SConscript
@@ -1,13 +1,13 @@
#!/usr/bin/python
Import ('env')
-sources = env.Glob('*.c') + env.Glob('*.cpp')
+sources = env.Glob('*.c')
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc ../../blenloader'
incs += ' ../../makesrna ../../python ../../ikplugin ../../bmesh'
incs += ' ../../render/extern/include ../../gpu' # for object_bake.c
-incs += ' #extern/recastnavigation/Recast/Include'
+incs += ' #extern/recastnavigation'
defs = []
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index f0df2431304..1260979ead8 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -927,7 +927,8 @@ static void multiresbake_start(MultiresBakeRender *bkr)
finish_images(bkr);
}
-static int multiresbake_check(bContext *C, wmOperator *op) {
+static int multiresbake_check(bContext *C, wmOperator *op)
+{
Scene *scene= CTX_data_scene(C);
Object *ob;
Mesh *me;
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 02e5f9e7e75..a4d16984c56 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -226,10 +226,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 */
diff --git a/source/blender/editors/object/object_navmesh.cpp b/source/blender/editors/object/object_navmesh.cpp
deleted file mode 100644
index ae97b40eb49..00000000000
--- a/source/blender/editors/object/object_navmesh.cpp
+++ /dev/null
@@ -1,628 +0,0 @@
-/**
-* $Id$
-*
-* ***** BEGIN GPL LICENSE BLOCK *****
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software Foundation,
-* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The Original Code is Copyright (C) 2004 by Blender Foundation
-* All rights reserved.
-*
-* The Original Code is: all of this file.
-*
-* Contributor(s): none yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*/
-
-#include <math.h>
-#include "Recast.h"
-
-extern "C"
-{
-#include "MEM_guardedalloc.h"
-
-#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"
-#include "BKE_depsgraph.h"
-#include "BKE_context.h"
-#include "BKE_mesh.h"
-#include "BKE_modifier.h"
-#include "BKE_scene.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_cdderivedmesh.h"
-#include "BLI_editVert.h"
-#include "BLI_listbase.h"
-#include "BLI_utildefines.h"
-#include "ED_object.h"
-#include "BLI_math_vector.h"
-
-#include "RNA_access.h"
-
-#include "ED_mesh.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);
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-static void createVertsTrisData(bContext *C, LinkNode* obs, int& nverts, float*& verts, int &ntris, int*& tris)
-{
- MVert *mvert;
- int nfaces = 0, *tri, i, curnverts, basenverts, curnfaces;
- MFace *mface;
- float co[3], wco[3];
- Object *ob;
- LinkNode *oblink, *dmlink;
- DerivedMesh *dm;
- Scene* scene = CTX_data_scene(C);
- LinkNode* dms = NULL;
-
- nverts = 0;
- ntris = 0;
- //calculate number of verts and tris
- for (oblink = obs; oblink; oblink = oblink->next)
- {
- ob = (Object*) oblink->link;
- DerivedMesh *dm = mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH);
- BLI_linklist_append(&dms, (void*)dm);
-
- nverts += dm->getNumVerts(dm);
- nfaces = dm->getNumFaces(dm);
- ntris += nfaces;
-
- //resolve quad faces
- mface = dm->getFaceArray(dm);
- for (i=0; i<nfaces; i++)
- {
- MFace* mf = &mface[i];
- if (mf->v4)
- ntris+=1;
- }
- }
-
- //create data
- verts = (float*) MEM_mallocN(sizeof(float)*3*nverts, "verts");
- tris = (int*) MEM_mallocN(sizeof(int)*3*ntris, "faces");
-
- basenverts = 0;
- tri = tris;
- for (oblink = obs, dmlink = dms; oblink && dmlink;
- oblink = oblink->next, dmlink = dmlink->next)
- {
- ob = (Object*) oblink->link;
- dm = (DerivedMesh*) dmlink->link;
-
- curnverts = dm->getNumVerts(dm);
- mvert = dm->getVertArray(dm);
- //copy verts
- for (i=0; i<curnverts; i++)
- {
- MVert *v = &mvert[i];
- copy_v3_v3(co, v->co);
- mul_v3_m4v3(wco, ob->obmat, co);
- verts[3*(basenverts+i)+0] = wco[0];
- verts[3*(basenverts+i)+1] = wco[2];
- verts[3*(basenverts+i)+2] = wco[1];
- }
-
- //create tris
- curnfaces = dm->getNumFaces(dm);
- mface = dm->getFaceArray(dm);
- for (i=0; i<curnfaces; i++)
- {
- MFace* mf = &mface[i];
- tri[0]= basenverts + mf->v1; tri[1]= basenverts + mf->v3; tri[2]= basenverts + mf->v2;
- tri += 3;
- if (mf->v4)
- {
- tri[0]= basenverts + mf->v1; tri[1]= basenverts + mf->v4; tri[2]= basenverts + mf->v3;
- tri += 3;
- }
- }
- basenverts += curnverts;
- }
-
- //release derived mesh
- for (dmlink = dms; dmlink; dmlink = dmlink->next)
- {
- dm = (DerivedMesh*) dmlink->link;
- dm->release(dm);
- }
- BLI_linklist_free(dms, NULL);
-}
-
-static bool buildNavMesh(const RecastData& recastParams, int nverts, float* verts, int ntris, int* tris,
- rcPolyMesh*& pmesh, rcPolyMeshDetail*& dmesh)
-{
- float bmin[3], bmax[3];
- rcHeightfield* solid;
- unsigned char *triflags;
- rcCompactHeightfield* chf;
- rcContourSet *cset;
-
- rcCalcBounds(verts, nverts, bmin, bmax);
-
- //
- // Step 1. Initialize build config.
- //
- rcConfig cfg;
- memset(&cfg, 0, sizeof(cfg));
- {
-/*
- float cellsize = 0.3f;
- float cellheight = 0.2f;
- float agentmaxslope = M_PI/4;
- float agentmaxclimb = 0.9f;
- float agentheight = 2.0f;
- float agentradius = 0.6f;
- float edgemaxlen = 12.0f;
- float edgemaxerror = 1.3f;
- float regionminsize = 50.f;
- float regionmergesize = 20.f;
- int vertsperpoly = 6;
- float detailsampledist = 6.0f;
- float detailsamplemaxerror = 1.0f;
- cfg.cs = cellsize;
- cfg.ch = cellheight;
- cfg.walkableSlopeAngle = agentmaxslope/M_PI*180.f;
- cfg.walkableHeight = (int)ceilf(agentheight/ cfg.ch);
- cfg.walkableClimb = (int)floorf(agentmaxclimb / cfg.ch);
- cfg.walkableRadius = (int)ceilf(agentradius / cfg.cs);
- cfg.maxEdgeLen = (int)(edgemaxlen/cellsize);
- cfg.maxSimplificationError = edgemaxerror;
- cfg.minRegionSize = (int)rcSqr(regionminsize);
- cfg.mergeRegionSize = (int)rcSqr(regionmergesize);
- cfg.maxVertsPerPoly = vertsperpoly;
- cfg.detailSampleDist = detailsampledist< 0.9f ? 0 : cellsize * detailsampledist;
- cfg.detailSampleMaxError = cellheight * detailsamplemaxerror;
-*/
- cfg.cs = recastParams.cellsize;
- cfg.ch = recastParams.cellheight;
- cfg.walkableSlopeAngle = recastParams.agentmaxslope/((float)M_PI)*180.f;
- cfg.walkableHeight = (int)ceilf(recastParams.agentheight/ cfg.ch);
- cfg.walkableClimb = (int)floorf(recastParams.agentmaxclimb / cfg.ch);
- cfg.walkableRadius = (int)ceilf(recastParams.agentradius / cfg.cs);
- cfg.maxEdgeLen = (int)(recastParams.edgemaxlen/recastParams.cellsize);
- cfg.maxSimplificationError = recastParams.edgemaxerror;
- cfg.minRegionSize = (int)rcSqr(recastParams.regionminsize);
- cfg.mergeRegionSize = (int)rcSqr(recastParams.regionmergesize);
- cfg.maxVertsPerPoly = recastParams.vertsperpoly;
- cfg.detailSampleDist = recastParams.detailsampledist< 0.9f ? 0 :
- recastParams.cellsize * recastParams.detailsampledist;
- cfg.detailSampleMaxError = recastParams.cellheight * recastParams.detailsamplemaxerror;
-
- }
-
- // Set the area where the navigation will be build.
- vcopy(cfg.bmin, bmin);
- vcopy(cfg.bmax, bmax);
- rcCalcGridSize(cfg.bmin, cfg.bmax, cfg.cs, &cfg.width, &cfg.height);
-
- //
- // Step 2. Rasterize input polygon soup.
- //
- // Allocate voxel heightfield where we rasterize our input data to.
- solid = new rcHeightfield;
- if (!solid)
- return false;
-
- if (!rcCreateHeightfield(*solid, cfg.width, cfg.height, cfg.bmin, cfg.bmax, cfg.cs, cfg.ch))
- return false;
-
- // Allocate array that can hold triangle flags.
- triflags = (unsigned char*) MEM_mallocN(sizeof(unsigned char)*ntris, "triflags");
- if (!triflags)
- return false;
- // Find triangles which are walkable based on their slope and rasterize them.
- memset(triflags, 0, ntris*sizeof(unsigned char));
- rcMarkWalkableTriangles(cfg.walkableSlopeAngle, verts, nverts, tris, ntris, triflags);
- rcRasterizeTriangles(verts, nverts, tris, triflags, ntris, *solid);
- MEM_freeN(triflags);
- MEM_freeN(verts);
- MEM_freeN(tris);
-
- //
- // Step 3. Filter walkables surfaces.
- //
- rcFilterLedgeSpans(cfg.walkableHeight, cfg.walkableClimb, *solid);
- rcFilterWalkableLowHeightSpans(cfg.walkableHeight, *solid);
-
- //
- // Step 4. Partition walkable surface to simple regions.
- //
-
- chf = new rcCompactHeightfield;
- if (!chf)
- return false;
- if (!rcBuildCompactHeightfield(cfg.walkableHeight, cfg.walkableClimb, RC_WALKABLE, *solid, *chf))
- return false;
-
- delete solid;
-
- // Prepare for region partitioning, by calculating distance field along the walkable surface.
- if (!rcBuildDistanceField(*chf))
- return false;
-
- // Partition the walkable surface into simple regions without holes.
- if (!rcBuildRegions(*chf, cfg.walkableRadius, cfg.borderSize, cfg.minRegionSize, cfg.mergeRegionSize))
- return false;
-
- //
- // Step 5. Trace and simplify region contours.
- //
- // Create contours.
- cset = new rcContourSet;
- if (!cset)
- return false;
-
- if (!rcBuildContours(*chf, cfg.maxSimplificationError, cfg.maxEdgeLen, *cset))
- return false;
-
- //
- // Step 6. Build polygons mesh from contours.
- //
- pmesh = new rcPolyMesh;
- if (!pmesh)
- return false;
- if (!rcBuildPolyMesh(*cset, cfg.maxVertsPerPoly, *pmesh))
- return false;
-
-
- //
- // Step 7. Create detail mesh which allows to access approximate height on each polygon.
- //
-
- dmesh = new rcPolyMeshDetail;
- if (!dmesh)
- return false;
-
- if (!rcBuildPolyMeshDetail(*pmesh, *chf, cfg.detailSampleDist, cfg.detailSampleMaxError, *dmesh))
- return false;
-
- delete chf;
- delete cset;
-
- return true;
-}
-
-static Object* createRepresentation(bContext *C, rcPolyMesh*& pmesh, rcPolyMeshDetail*& dmesh, Base* base)
-{
- float co[3], rot[3];
- EditMesh *em;
- int i,j, k;
- unsigned short* v;
- int face[3];
- Main *bmain = CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object* obedit;
- int createob = base==NULL;
- zero_v3(co);
- zero_v3(rot);
- if (createob)
- {
- //create new object
- obedit = ED_object_add_type(C, OB_MESH, co, rot, FALSE, 1);
- }
- else
- {
- obedit = base->object;
- scene_select_base(scene, base);
- copy_v3_v3(obedit->loc, co);
- copy_v3_v3(obedit->rot, rot);
- }
-
- ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER);
- em = BKE_mesh_get_editmesh(((Mesh *)obedit->data));
-
- if (!createob)
- {
- //clear
- if(em->verts.first) free_vertlist(em, &em->verts);
- if(em->edges.first) free_edgelist(em, &em->edges);
- if(em->faces.first) free_facelist(em, &em->faces);
- if(em->selected.first) BLI_freelistN(&(em->selected));
- }
-
- //create verts for polygon mesh
- for(i = 0; i < pmesh->nverts; i++) {
- v = &pmesh->verts[3*i];
- co[0] = pmesh->bmin[0] + v[0]*pmesh->cs;
- co[1] = pmesh->bmin[1] + v[1]*pmesh->ch;
- co[2] = pmesh->bmin[2] + v[2]*pmesh->cs;
- SWAP(float, co[1], co[2]);
- addvertlist(em, co, NULL);
- }
-
- //create custom data layer to save polygon idx
- CustomData_add_layer_named(&em->fdata, CD_RECAST, CD_CALLOC, NULL, 0, "recastData");
-
- //create verts and faces for detailed mesh
- for (i=0; i<dmesh->nmeshes; i++)
- {
- int uniquevbase = em->totvert;
- unsigned short vbase = dmesh->meshes[4*i+0];
- unsigned short ndv = dmesh->meshes[4*i+1];
- unsigned short tribase = dmesh->meshes[4*i+2];
- unsigned short trinum = dmesh->meshes[4*i+3];
- const unsigned short* p = &pmesh->polys[i*pmesh->nvp*2];
- int nv = 0;
- for (j = 0; j < pmesh->nvp; ++j)
- {
- if (p[j] == 0xffff) break;
- nv++;
- }
- //create unique verts
- for (j=nv; j<ndv; j++)
- {
- copy_v3_v3(co, &dmesh->verts[3*(vbase + j)]);
- SWAP(float, co[1], co[2]);
- addvertlist(em, co, NULL);
- }
-
- EM_init_index_arrays(em, 1, 0, 0);
-
- //create faces
- for (j=0; j<trinum; j++)
- {
- unsigned char* tri = &dmesh->tris[4*(tribase+j)];
- EditFace* newFace;
- for (k=0; k<3; k++)
- {
- if (tri[k]<nv)
- face[k] = p[tri[k]]; //shared vertex
- else
- face[k] = uniquevbase+tri[k]-nv; //unique vertex
- }
- newFace = addfacelist(em, EM_get_vert_for_index(face[0]), EM_get_vert_for_index(face[2]),
- EM_get_vert_for_index(face[1]), NULL, NULL, NULL);
-
- //set navigation polygon idx to the custom layer
- int* polygonIdx = (int*)CustomData_em_get(&em->fdata, newFace->data, CD_RECAST);
- *polygonIdx = i+1; //add 1 to avoid zero idx
- }
-
- EM_free_index_arrays();
- }
-
- delete pmesh; pmesh = NULL;
- delete dmesh; dmesh = NULL;
-
- BKE_mesh_end_editmesh((Mesh*)obedit->data, em);
-
- DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
-
-
- ED_object_exit_editmode(C, EM_FREEDATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
-
- if (createob)
- {
- obedit->gameflag &= ~OB_COLLISION;
- obedit->gameflag |= OB_NAVMESH;
- obedit->body_type = OB_BODY_TYPE_NAVMESH;
- rename_id((ID *)obedit, "Navmesh");
- }
-
- ModifierData *md= modifiers_findByType(obedit, eModifierType_NavMesh);
- if (!md)
- {
- ED_object_modifier_add(NULL, bmain, scene, obedit, NULL, eModifierType_NavMesh);
- }
-
- return obedit;
-}
-
-static int create_navmesh_exec(bContext *C, wmOperator *op)
-{
- Scene* scene = CTX_data_scene(C);
- int nverts, ntris;
- float* verts;
- int* tris;
- rcPolyMesh* pmesh;
- rcPolyMeshDetail* dmesh;
- LinkNode* obs = NULL;
- Base* navmeshBase = NULL;
- //CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) //expand macros to avoid error in convertion from void*
- {
- ListBase ctx_data_list;
- CollectionPointerLink *ctx_link;
- CTX_data_selected_editable_bases(C, &ctx_data_list);
- for(ctx_link = (CollectionPointerLink *)ctx_data_list.first;
- ctx_link; ctx_link = (CollectionPointerLink *)ctx_link->next) {
- Base* base= (Base*)ctx_link->ptr.data;
- {
- if (base->object->body_type==OB_BODY_TYPE_NAVMESH)
- {
- if (!navmeshBase || base==CTX_data_active_base(C))
- navmeshBase = base;
- }
- else
- BLI_linklist_append(&obs, (void*)base->object);
- }
- CTX_DATA_END;
- createVertsTrisData(C, obs, nverts, verts, ntris, tris);
- BLI_linklist_free(obs, NULL);
- buildNavMesh(scene->gm.recastData, nverts, verts, ntris, tris, pmesh, dmesh);
- createRepresentation(C, pmesh, dmesh, navmeshBase);
-
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_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";
-
- /* api callbacks */
- ot->exec= create_navmesh_exec;
-
- /* flags */
- 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 *op)
-{
- Object *obedit= CTX_data_edit_object(C);
- EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
- //do work here
- int targetPolyIdx = -1;
- EditFace *ef, *efa;
- efa = EM_get_actFace(em, 0);
- if (efa)
- {
- if (CustomData_has_layer(&em->fdata, CD_RECAST))
- {
- targetPolyIdx = *(int*)CustomData_em_get(&em->fdata, efa->data, CD_RECAST);
- targetPolyIdx = targetPolyIdx>=0? targetPolyIdx : -targetPolyIdx;
- if (targetPolyIdx>0)
- {
- //set target poly idx to other selected faces
- ef = (EditFace*)em->faces.last;
- while(ef)
- {
- if((ef->f & SELECT )&& ef!=efa)
- {
- int* recastDataBlock = (int*)CustomData_em_get(&em->fdata, ef->data, CD_RECAST);
- *recastDataBlock = targetPolyIdx;
- }
- ef = ef->prev;
- }
- }
- }
- }
-
- DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
-
- BKE_mesh_end_editmesh((Mesh*)obedit->data, em);
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_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";
-
- /* api callbacks */
- ot->poll = assign_navpolygon_poll;
- ot->exec= assign_navpolygon_exec;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-
-static int compare(const void * a, const void * b){
- return ( *(int*)a - *(int*)b );
-}
-static int findFreeNavPolyIndex(EditMesh* em)
-{
- //construct vector of indices
- int numfaces = em->totface;
- int* indices = new int[numfaces];
- EditFace* ef = (EditFace*)em->faces.last;
- int idx = 0;
- while(ef)
- {
- int polyIdx = *(int*)CustomData_em_get(&em->fdata, ef->data, CD_RECAST);
- indices[idx] = polyIdx;
- idx++;
- ef = ef->prev;
- }
- qsort(indices, numfaces, sizeof(int), compare);
- //search first free index
- int freeIdx = 1;
- for (int i=0; i<numfaces; i++)
- {
- if (indices[i]==freeIdx)
- freeIdx++;
- else if (indices[i]>freeIdx)
- break;
- }
- delete [] indices;
- return freeIdx;
-}
-
-static int assign_new_navpolygon_exec(bContext *C, wmOperator *op)
-{
- Object *obedit= CTX_data_edit_object(C);
- EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
- EditFace *ef;
- if (CustomData_has_layer(&em->fdata, CD_RECAST))
- {
- int targetPolyIdx = findFreeNavPolyIndex(em);
- if (targetPolyIdx>0)
- {
- //set target poly idx to selected faces
- ef = (EditFace*)em->faces.last;
- while(ef)
- {
- if(ef->f & SELECT )
- {
- int* recastDataBlock = (int*)CustomData_em_get(&em->fdata, ef->data, CD_RECAST);
- *recastDataBlock = targetPolyIdx;
- }
- ef = ef->prev;
- }
- }
- }
-
- DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
-
- BKE_mesh_end_editmesh((Mesh*)obedit->data, em);
- return OPERATOR_FINISHED;
-}
-
-void OBJECT_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";
-
- /* api callbacks */
- ot->poll = assign_navpolygon_poll;
- ot->exec= assign_new_navpolygon_exec;
-
- /* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-}
-}
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index f115642cf8e..e083528e2ca 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -216,12 +216,6 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_drop_named_material);
WM_operatortype_append(OBJECT_OT_test_multires);
-
-#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
}
void ED_operatormacros_object(void)
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 866a0c1c495..4bee89ef3ba 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -758,7 +758,8 @@ static void vgroup_normalize(Object *ob)
It returns the number that it added (0-2)
It relies on verts having -1 for unassigned indices
*/
-static int tryToAddVerts(int *verts, int length, int a, int b) {
+static int tryToAddVerts(int *verts, int length, int a, int b)
+{
char containsA = FALSE;
char containsB = FALSE;
int added = 0;
@@ -788,7 +789,8 @@ and returns an array of indices of size count
count is an int passed by reference so it can be assigned the value of the length here.
*/
-static int* getSurroundingVerts(Mesh *me, int vert, int *count) {
+static int* getSurroundingVerts(Mesh *me, int vert, int *count)
+{
int length = 0;
int *tverts;
int *verts = NULL;
@@ -850,7 +852,8 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count) {
/* get a single point in space by averaging a point cloud (vectors of size 3)
coord is the place the average is stored, points is the point cloud, count is the number of points in the cloud
*/
-static void getSingleCoordinate(MVert *points, int count, float coord[3]) {
+static void getSingleCoordinate(MVert *points, int count, float coord[3])
+{
int i;
zero_v3(coord);
for(i = 0; i < count; i++) {
@@ -877,7 +880,8 @@ static void getNearestPointOnPlane(const float norm[3], const float coord[3], co
}
/* distance of two vectors a and b of size length */
-static float distance(float* a, float *b, int length) {
+static float distance(float* a, float *b, int length)
+{
int i;
float sum = 0;
for(i = 0; i < length; i++) {
@@ -890,7 +894,8 @@ static float distance(float* a, float *b, int length) {
compute the amount of vertical distance relative to the plane and store it in dists,
then get the horizontal and vertical change and store them in changes
*/
-static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, float *start, float distToStart, float *end, float (*changes)[2], float *dists, int index) {
+static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, float *start, float distToStart, float *end, float (*changes)[2], float *dists, int index)
+{
// A=Q-((Q-P).N)N
// D = (a*x0 + b*y0 +c*z0 +d)
float projA[3] = {0}, projB[3] = {0};
@@ -908,7 +913,8 @@ static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, f
}
// I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc)
-static void dm_deform_clear(DerivedMesh *dm, Object *ob) {
+static void dm_deform_clear(DerivedMesh *dm, Object *ob)
+{
if(ob->derivedDeform && (ob->derivedDeform)==dm) {
ob->derivedDeform->needsFree = 1;
ob->derivedDeform->release(ob->derivedDeform);
@@ -921,7 +927,8 @@ static void dm_deform_clear(DerivedMesh *dm, Object *ob) {
}
// recalculate the deformation
-static DerivedMesh* dm_deform_recalc(Scene *scene, Object *ob) {
+static DerivedMesh* dm_deform_recalc(Scene *scene, Object *ob)
+{
return mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
}
@@ -933,7 +940,8 @@ index is the index of the vertex being moved
norm and d are the plane's properties for the equation: ax + by + cz + d = 0
coord is a point on the plane
*/
-static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float norm[3], float coord[3], float d, float distToBe, float strength, float cp) {
+static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float norm[3], float coord[3], float d, float distToBe, float strength, float cp)
+{
DerivedMesh *dm;
MDeformWeight *dw;
MVert m;
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 11796d01620..2f62e55bcd8 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -844,7 +844,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
return;
}
-static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
+static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, short do_job)
{
Scene *scene= CTX_data_scene(C);
int i;
@@ -871,12 +871,10 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
ListBase *fobjects = MEM_callocN(sizeof(ListBase), "fluid objects");
FluidsimModifierData *fluidmd = NULL;
Mesh *mesh = NULL;
-
- wmJob *steve;
+
FluidBakeJob *fb;
elbeemSimulationSettings *fsset= MEM_callocN(sizeof(elbeemSimulationSettings), "Fluid sim settings");
-
- steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS);
+
fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job");
if(getenv(strEnvName)) {
@@ -1083,12 +1081,25 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
/* custom data for fluid bake job */
fb->settings = fsset;
- /* setup job */
- WM_jobs_customdata(steve, fb, fluidbake_free);
- WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME);
- WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, fluidbake_endjob);
-
- WM_jobs_start(CTX_wm_manager(C), steve);
+ if(do_job) {
+ wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS);
+
+ /* setup job */
+ WM_jobs_customdata(steve, fb, fluidbake_free);
+ WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME);
+ WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, fluidbake_endjob);
+
+ WM_jobs_start(CTX_wm_manager(C), steve);
+ }
+ else {
+ short dummy_stop, dummy_do_update;
+ float dummy_progress;
+
+ /* blocking, use with exec() */
+ fluidbake_startjob((void *)fb, &dummy_stop, &dummy_do_update, &dummy_progress);
+ fluidbake_endjob((void *)fb);
+ fluidbake_free((void *)fb);
+ }
/* ******** free stored animation data ******** */
fluidbake_free_data(channels, fobjects, NULL, NULL);
@@ -1121,7 +1132,7 @@ FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss))
}
/* only compile dummy functions */
-static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object *UNUSED(ob))
+static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object *UNUSED(ob), short UNUSED(do_job))
{
return 0;
}
@@ -1130,13 +1141,21 @@ static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object
/***************************** Operators ******************************/
-static int fluid_bake_exec(bContext *C, wmOperator *op)
+static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
/* only one bake job at a time */
if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C)))
return 0;
- if(!fluidsimBake(C, op->reports, CTX_data_active_object(C)))
+ if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE))
+ return OPERATOR_CANCELLED;
+
+ return OPERATOR_FINISHED;
+}
+
+static int fluid_bake_exec(bContext *C, wmOperator *op)
+{
+ if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -1150,6 +1169,7 @@ void FLUID_OT_bake(wmOperatorType *ot)
ot->idname= "FLUID_OT_bake";
/* api callbacks */
+ ot->invoke= fluid_bake_invoke;
ot->exec= fluid_bake_exec;
ot->poll= ED_operator_object_active_editable;
}
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 589d652a275..827c14b1c0d 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -364,7 +364,8 @@ void fdrawXORcirc(float xofs, float yofs, float rad)
set_inverted_drawing(0);
}
-void glutil_draw_filled_arc(float start, float angle, float radius, int nsegments) {
+void glutil_draw_filled_arc(float start, float angle, float radius, int nsegments)
+{
int i;
glBegin(GL_TRIANGLE_FAN);
@@ -378,7 +379,8 @@ void glutil_draw_filled_arc(float start, float angle, float radius, int nsegment
glEnd();
}
-void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments) {
+void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments)
+{
int i;
glBegin(GL_LINE_STRIP);
@@ -797,7 +799,8 @@ void bglBegin(int mode)
}
}
-int bglPointHack(void) {
+int bglPointHack(void)
+{
float value[4];
int pointhack_px;
glGetFloatv(GL_POINT_SIZE_RANGE, value);
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 354e81cb52c..45724f0f32f 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1857,11 +1857,13 @@ static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2],
/* Clip the face by a bucket and set the uv-space bucket_bounds_uv
* so we have the clipped UV's to do pixel intersection tests with
* */
-static int float_z_sort_flip(const void *p1, const void *p2) {
+static int float_z_sort_flip(const void *p1, const void *p2)
+{
return (((float *)p1)[2] < ((float *)p2)[2] ? 1:-1);
}
-static int float_z_sort(const void *p1, const void *p2) {
+static int float_z_sort(const void *p1, const void *p2)
+{
return (((float *)p1)[2] < ((float *)p2)[2] ?-1:1);
}
@@ -3690,7 +3692,8 @@ static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, float
}
}
-static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask, int use_color_correction) {
+static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask, int use_color_correction)
+{
if (ps->is_texbrush) {
/* rgba already holds a texture result here from higher level function */
float rgba_br[3];
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 512fa781fc2..fc7e5593e5a 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -154,7 +154,7 @@ static int sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob)
if(mmd) return 0;
- /* non-locked shaoe keys could be handled in the same way as deformed mesh */
+ /* non-locked shape keys could be handled in the same way as deformed mesh */
if((ob->shapeflag&OB_SHAPE_LOCK)==0 && me->key && ob->shapenr)
return 1;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index c7ada4a5801..c2e45c5ad8a 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -244,7 +244,8 @@ static int compare_size(const void *a1, const void *a2)
else return BLI_natstrcmp(entry1->relname,entry2->relname);
}
-static int compare_extension(const void *a1, const void *a2) {
+static int compare_extension(const void *a1, const void *a2)
+{
const struct direntry *entry1=a1, *entry2=a2;
const char *sufix1, *sufix2;
const char *nil="";
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 3a4371e8bb9..eec8bfb469b 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -1747,6 +1747,7 @@ static int get_col_actuator(int type)
case ACT_CONSTRAINT: return TH_PANEL;
case ACT_STATE: return TH_PANEL;
case ACT_ARMATURE: return TH_PANEL;
+ case ACT_STEERING: return TH_PANEL;
default: return TH_PANEL;
}
}
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 916e59eae9c..baa755ef841 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -3266,7 +3266,8 @@ void NODE_OT_delete(wmOperatorType *ot)
}
/* ****************** Delete with reconnect ******************* */
-static int is_connected_to_input_socket(bNode* node, bNodeLink* link) {
+static int is_connected_to_input_socket(bNode* node, bNodeLink* link)
+{
bNodeSocket *sock;
if (link->tonode == node) {
for(sock= node->inputs.first; sock; sock= sock->next) {
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index c0919ef3043..3ea27899128 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -530,7 +530,8 @@ void SEQUENCER_OT_select(wmOperatorType *ot)
/* run recursivly to select linked */
-static int select_more_less_seq__internal(Scene *scene, int sel, int linked) {
+static int select_more_less_seq__internal(Scene *scene, int sel, int linked)
+{
Editing *ed= seq_give_editing(scene, FALSE);
Sequence *seq, *neighbor;
int change=0;
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 76074b84136..cb7ee18e829 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1762,7 +1762,8 @@ static void drawSelectedVertices__mapFunc(void *userData, int index, float *co,
}
}
-static void drawSelectedVertices(DerivedMesh *dm, Mesh *me) {
+static void drawSelectedVertices(DerivedMesh *dm, Mesh *me)
+{
glBegin(GL_POINTS);
dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, me->mvert);
glEnd();
diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c
index a949c6a2aa4..3cb11b95665 100644
--- a/source/blender/editors/space_view3d/view3d_buttons.c
+++ b/source/blender/editors/space_view3d/view3d_buttons.c
@@ -1237,7 +1237,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
Object *ob= OBACT;
// TransformProperties *tfp; // UNUSED
PointerRNA obptr;
- uiLayout *col, *row;
+ uiLayout *col /* , *row */ /* UNUSED */;
float lim;
if(ob==NULL) return;
@@ -1265,7 +1265,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
col= uiLayoutColumn(pa->layout, 0);
- row= uiLayoutRow(col, 0);
+ /* row= uiLayoutRow(col, 0); */ /* UNUSED */
RNA_id_pointer_create(&ob->id, &obptr);
if(ob==obedit) {
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 0854f9f3685..d3d7b1b1505 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -3226,7 +3226,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve
else
WM_event_add_notifier(C, NC_SCENE|NA_EDITED, scene);
- return OPERATOR_FINISHED;
+ return OPERATOR_PASS_THROUGH;
}
void VIEW3D_OT_cursor3d(wmOperatorType *ot)
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 50cf1518ada..89bfad1693e 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1787,7 +1787,7 @@ static int game_engine_exec(bContext *C, wmOperator *op)
{
#ifdef WITH_GAMEENGINE
Scene *startscene = CTX_data_scene(C);
- ScrArea *sa, *prevsa= CTX_wm_area(C);
+ ScrArea /* *sa, */ /* UNUSED */ *prevsa= CTX_wm_area(C);
ARegion *ar, *prevar= CTX_wm_region(C);
wmWindow *prevwin= CTX_wm_window(C);
RegionView3D *rv3d;
@@ -1800,7 +1800,7 @@ static int game_engine_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
rv3d= CTX_wm_region_view3d(C);
- sa= CTX_wm_area(C);
+ /* sa= CTX_wm_area(C); */ /* UNUSED */
ar= CTX_wm_region(C);
view3d_operator_needs_opengl(C);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 7fe2675c7c0..c633efd7486 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1272,7 +1272,8 @@ void applyTransObjects(TransInfo *t)
recalcData(t);
}
-static void restoreElement(TransData *td) {
+static void restoreElement(TransData *td)
+{
/* TransData for crease has no loc */
if (td->loc) {
copy_v3_v3(td->loc, td->iloc);
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index b3608305a7a..a1e1c0e0b1d 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -118,7 +118,8 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const int mval[
output[1] *= mi->factor;
}
-static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) {
+static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
+{
float x, pad;
pad = t->ar->winx / 10;
@@ -135,7 +136,8 @@ static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const int mval[2]
output[0] = (x - pad) / (t->ar->winx - 2 * pad);
}
-static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) {
+static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
+{
float vec[3];
InputVector(t, mi, mval, vec);
@@ -144,7 +146,8 @@ static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const int mval
output[0] = dot_v3v3(t->viewinv[0], vec) * 2.0f;
}
-static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) {
+static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
+{
float y, pad;
pad = t->ar->winy / 10;
@@ -160,7 +163,8 @@ static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const int mval[2],
output[0] = (y - pad) / (t->ar->winy - 2 * pad);
}
-static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3]) {
+static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const int mval[2], float output[3])
+{
float vec[3];
InputVector(t, mi, mval, vec);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 91adf0302a4..a0674b772fa 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1602,7 +1602,8 @@ static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, flo
return retval;
}
-static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, float mval[2], int *dist, float *loc, float *no, SnapMode mode) {
+static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, float mval[2], int *dist, float *loc, float *no, SnapMode mode)
+{
Base *base;
float depth = FLT_MAX;
int retval = 0;
@@ -1934,7 +1935,8 @@ int peelObjectsContext(bContext *C, ListBase *depth_peels, float mval[2])
static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], GearsType action);
-void snapGridAction(TransInfo *t, float *val, GearsType action) {
+void snapGridAction(TransInfo *t, float *val, GearsType action)
+{
float fac[3];
fac[NO_GEARS] = t->snap[0];
@@ -1945,7 +1947,8 @@ void snapGridAction(TransInfo *t, float *val, GearsType action) {
}
-void snapGrid(TransInfo *t, float *val) {
+void snapGrid(TransInfo *t, float *val)
+{
GearsType action;
// Only do something if using Snap to Grid