Commit Graph

43 Commits

Author SHA1 Message Date
Sybren A. Stüvel
d3acfa1d87 BGE: Navmesh fixes and improvements
The navigation mesh functionality was broken for quite a while. This patch
contains fixes: recalculating tesselations before getting the number of
tesselation faces (it otherwise returned 0) before calculating the navmesh,
and calling `DM_ensure_tessface()` on the navmesh's `DerivedMesh` object
(which fixes visualisation in Blender). This allows one to create a new
navmesh, which also works in the BGE.

Furthermore, the patch adds several return values, and shows more error
messages when things go wrong. In several places in the navmesh creation
code, return codes weren't checked and errors silently ignored.

Reviewers: nicks, brita_, campbellbarton, lordloki, moguri, panzergame

Reviewed By: panzergame

Differential Revision: https://developer.blender.org/D1435
2015-07-28 13:54:41 +02:00
Jorge Bernal
6ffc988ae3 BGE Clean-up: New EXP prefix for the BGE Expression module
The expression module now uses an EXP prefix and it follows a
distribution similar to blender.

Additionally the hash function in EXP_HashedPtr.h was simplified and the
files EXP_C-Api.h &.EXP_C-Api.cpp were deleted because were unused.

Reviewers: campbellbarton, moguri, sybren, hg1

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1221
2015-07-12 16:58:12 +02:00
Benoit Bolsee
8aa203abc1 BGE: fix a bug causing frequent crash on scene restart with navmesh. 2014-08-10 00:40:15 +02:00
Mitchell Stokes
3b3908020e BGE cleanup: Removing some potential memory leaks from KX_NavMeshObject when it fails to build a navmesh. 2014-05-27 14:19:45 -07:00
Mitchell Stokes
1d1560eec4 BGE: Fixing some NavMesh memory leaks. 2014-05-13 15:52:07 -07:00
Mitchell Stokes
fb94a53978 BGE Rasterizer Cleanup: Cleaning up some includes. 2013-11-04 19:22:10 +00:00
Campbell Barton
59cdb0d65d fix memory leak with navmesh 2013-11-02 04:22:08 +00:00
Campbell Barton
93f5e2218a code cleanup: replace strncpy -> BLI_strncpy, skip first 2 chars when making a hash from the object name. 2013-08-04 03:45:30 +00:00
Campbell Barton
704598ef4e avoid freeing NULL pointer for navmesh BuildVertIndArrays and dont truncate memset arg. 2013-08-04 03:02:35 +00:00
Campbell Barton
dad877bc3b fix for BGE crash replicating a navmesh. 2013-03-22 20:19:55 +00:00
Campbell Barton
ddc2dbc2a4 style cleanup 2012-10-22 08:15:51 +00:00
Campbell Barton
bc8f602601 style cleanup 2012-10-20 18:46:57 +00:00
Campbell Barton
2fb8292005 style cleanup 2012-09-16 04:58:18 +00:00
Sergey Sharybin
caafc8184b Fix #30720: Creating Navmesh crashes blender
In fact there were several issues fixed (all of them regressions since bmesh merge):

- Creating navmesh crashed because creating new faces for mesh was trying to set
  default values for all customdata layers in this face. This requires memory
  pool created for this datablock.
  Usually this pool is creating on creating datablock if there're some elements
  to be stored in this block. In cases of regular primitive creating it wasn't
  an issue because they doesn't create customdata layers, they only creates
  geometry.
  Navigation mesh creates geometry and customdata layers (CD_RECAST layer)
  which used to confuse a bit custom data functions. Solved by ensuring there's
  memory pool created for polygons datablock after adding new custom data layer.
  Most probably it's better to be resolved on CD level (like smarter track on
  changed amount of stored data and so) but prefer not to make such global changes
  so close to the release.
- Toggling edit mode lead to loosing recast datalayer. Solved by adding recast
  layer to bmesh mask so it'll be copied to/from edit mesh.
- Some part of code assumed raycast layer is in face datablock, some that it's in
  polygon datablock. Made it to be in polygons datablock.
  Kind of temporary solution to make navmesh working, probably it'll fail if one
  will want to edit navmesh by hand after it was generated.
  Proper way would be to ensure the whole navmesh things are using ngons.
2012-04-16 13:53:30 +00:00
Campbell Barton
5b88712ff9 move debug flag into its own global var (G.debug), split up debug options.
--debug
  --debug-ffmpeg
  --debug-python
  --debug-events
  --debug-wm

This makes debug output easier to read - event debug prints would flood output too much before.

For convenience:
  --debug-all turns all debug flags on (works as --debug did before).

also removed some redundant whitespace in debug prints and prefix some prints with __func__ to give some context.
2012-03-31 00:59:17 +00:00
Campbell Barton
b8a71efeba style cleanup: follow style guide for/with/if spacing 2012-03-24 07:52:14 +00:00
Campbell Barton
640d766370 style cleanup - remove unneeded ';'s 2012-03-08 03:05:57 +00:00
Campbell Barton
075fee4d58 svn merge ^/trunk/blender -r43830:43864 2012-02-03 01:30:21 +00:00
Sergey Sharybin
6a30321434 Fix #29381: Navmeshs frees not guarded allocated memory and leaked
There were two issues discovered:
- Triangles mapping didn't free in buildNavMeshData if there's no recast data for an object
- KX_NavMeshObject used not-guarded allocation for polygons storage, but used guarded
  freeing stuff to free used memory, producing error messages in the console and leading to
  memory leak.

Wasn't actually harmful for users -- there was no memory corruptions and error happens only
when object was set up in a way when navmesh can't work in theory.
2012-02-02 08:48:43 +00:00
Joseph Eagar
aea95c7860 bmesh: fixed merge issues with navmesh (though I've not tested if it works yet).
also fixed a small crasher in bridge.
2011-11-08 00:20:50 +00:00
Campbell Barton
4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Benoit Bolsee
e6a9b68c79 Recast: upgrade library.
- Upgrade Recast library to latest portable version
- Implement recast_qsort based on FreeBSD qsort.c to have 
  portable thread safe quick sort for use in conversion routine.
- Better default value for the Build Navigation Mesh operator
2011-09-29 21:38:57 +00:00
Sergey Sharybin
0169079bd1 Get rid of c++ in blenkernel and modifiers
Also use guarded allocations for navmesh stuff.
2011-09-20 16:24:50 +00:00
Benoit Bolsee
b988a2abf8 Recast: fix bad level calls, Recast compiled out if BGE not enabled. SCons updated but not tested. 2011-09-11 14:13:04 +00:00
Sergey Sharybin
bdd4aa27b0 Another set of fixes for recats: osx uses different order of arguments for sort_r
and it's callback.

Also do not use char constants like 'NAVM' which is casting to int.
And added defautl section to switch in KX_NavMeshObject::DrawNavMesh.
2011-09-10 14:12:15 +00:00
Campbell Barton
357febc168 fix for building with collada and some other warnings 2011-09-10 09:38:38 +00:00
Campbell Barton
0128218254 recast and detour patch now builds again with GCC
- rearrange structs to work for 64bit
- define all vars before goto's
- ifdefs for qsort_r/qsort_s
- dont cast pointers to int only for NULL checks
- dont printf STR_String directly, get the char pointer from it

also minor change to gpu py module, no need to pass empty tuple to PyObject_CallObject, can just be NULL
2011-09-10 03:07:26 +00:00
Guillermo S. Romero
a7f3e347b7 SVN maintenance. 2011-09-09 22:02:12 +00:00
Nick Samarin
a918040902 synched with trunk at revision 36569 2011-05-16 20:30:59 +00:00
Nick Samarin
dbc8d4274f - moved navmesh conversion code to ED_Editors project (ED_navmesh_conversion.h and navmesh_conversion.cpp files)
- added new custom data layer CD_Recast
2010-07-30 13:02:32 +00:00
Nick Samarin
14171324b7 - reworked conversion to dtStatNavMesh in KX_NavMeshObject to support navigation mesh editing 2010-07-28 19:43:05 +00:00
Nick Samarin
af1ca0cfc1 - added operators for manual assigning navigation polygon idx to mesh faces in edit mode
- modified conversion process to take into account changes caused by mesh editing
Note: conversion to dtStatNavMesh in KX_NavMeshObject hasn't worked correctly yet
2010-07-27 21:01:00 +00:00
Nick Samarin
e8d129cc76 - added custom get function for navmesh property of steering actuator to accept only objects with NavMesh physics type
- fixed the access to KX_SteeringActuator attributes from scripts
- added enum members for KX_SteeringActuator and KX_NavMeshObject to GameLogic dictionary
2010-07-21 09:16:27 +00:00
Nick Samarin
b4b9e01f8d - set defaults to steering actuator parameters
- fixed order of triangle indexes for navigation mesh representation
2010-07-20 14:09:05 +00:00
Nick Samarin
0fbca1dc19 - added options to enable visualization for obstacle simulation and steering actuator
- added python attributes for parameters of steering actuator
2010-07-15 18:41:29 +00:00
Nick Samarin
219e9022b9 - set default value for level height params
- added flag OPTYPE_UNDO for navmesh operator to enable undo operation
2010-07-14 20:09:04 +00:00
Nick Samarin
b17f90b22c - fixed bugs with unique vertices of detailed mesh in generation and conversion of navigation mesh
- set default physic type and name for navigation mesh object
2010-07-14 13:20:13 +00:00
Nick Samarin
852b84745c Work on conversion of the navigation mesh: we build navmesh directly from blender mesh using custom face data, when no custom data provided we use RAS_MeshObject interface 2010-07-09 22:22:51 +00:00
Nick Samarin
4fb80f36e2 added actual creation of navigation mesh for navmesh modifier 2010-06-25 21:08:23 +00:00
Nick Samarin
c92d0dfdf6 Added:
- obstacle culling for correct simulation in 3d
- flag for steering actuator termination on reaching target
- path recalculation period
- advance by waypoints (for path following)
2010-06-18 23:48:52 +00:00
Nick Samarin
700c32e738 - registration obstacle in game object
- creation obstacle on object replication (including navmesh object)
- creation object transform for navigation mesh directly from blender object instead of using SGNode world transform (because SGNode doesn't exists yet when building navmesh  on ProcessReplica)
2010-06-16 00:23:24 +00:00
Nick Samarin
9d1b8bf0f8 Added segment obstacles, creation obstacles for walls of navigation mesh 2010-06-07 23:09:50 +00:00
Nick Samarin
05b92f0fc9 Added new actuator type for following steering behaviors: seek, flee, path following; renamed KX_Pathfinder to KX_NavMeshObject 2010-05-31 22:35:22 +00:00