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
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
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.
--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.
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.
- 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
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.
- 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
- modified conversion process to take into account changes caused by mesh editing
Note: conversion to dtStatNavMesh in KX_NavMeshObject hasn't worked correctly yet
- fixed the access to KX_SteeringActuator attributes from scripts
- added enum members for KX_SteeringActuator and KX_NavMeshObject to GameLogic dictionary
- obstacle culling for correct simulation in 3d
- flag for steering actuator termination on reaching target
- path recalculation period
- advance by waypoints (for path following)
- 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)