This problem might have been introduced in 06270eaac0 but not sure.
The crash could happen due to a use-after-free memory access:
When deleting an entity with skel in postInit(), deletion would be
delayed by 1 frame because that is how entity_delete() works.
During deletion, RenderObject::children were removed and deleted
but SkeletalSprite::bones still had those pointers.
Additionally an object would delete its children in onUpdate() after
safeKill(), and still proceed to run scripts, which would then possibly
access freed memory too.
This fix causes children to not be deleted until we're out of the update()
cycle, and instead delete children together with the root object.
Also removes Lua functions:
- obj_setOverrideRenderPass()
* entity_setRenderPass() is now the same as obj_setRenderPass(),
without the special case alternate name in Lua
Observations:
- Entity::renderPass was never set to RENDER_ALL -> can simplify some things
- The initial pass check in RenderObject::render() was constant for each pass
-> All logic that is per-pass-constant can be moved to a renderability pre-check
- Core::overrideStartLayer, Core::overrideEndLayer, Core::rlayer were never used
- Should be possible eventually to prepare & render layers in parallel
I am not sure if the changes in this commit are 100% correct, but layer passes
are still working and the hug looks like it should.
Thinking about it, the overrideRenderPass functionality should never have existed.
The game scripts don't actually use entity_setRenderPass
(which in turn calls Entity::setOverrideRenderPass())
so I might remove that function in a future commit,
together with the rest of the "override" functionality.
SkeletalSprite was the only thing using it.
Instead of PM_STATIC it's now added to its Entity as PM_NONE.
PM_NONE is not auto-updated so SkeletalSprite::update() is now called
at the end of Entity::onUpdate()
(There's now a bug that during spirit form the screen stays black,
probably added that in an earlier commit. Will fix.)
(On second tought, maybe ParentManaged should be boolean.
Instead add a noAutoUpdate flag. But i'll save that for another time when i get around
to move all RenderObject bools into a bitmask.)
This untangles some of the gigantic kitchen sink headers
in an attempt to split things into smaller files.
Also don't include gl.h, glext.h, windows.h,
and other such nonsense *everywhere*.
Lots of cleanups on the way too. More dead/unused code removal.
Remove incrFlag(), decrFlag() Lua functions.
Another vector that was always empty, optionally filled when specified
by a skeletal file, but none actually did this. Should be safe to remove.
Also small related optimization in Game::collideSkeletalVsCircle().
This was always (0, 0) and optionally used for bones if defined in skeletal files.
None of the official skeletal files used this, so this should be safe to remove.
Should cause less GL pipeline stalling / driver spinlocking if enabled.
Disable AQUARIA_USE_GLM (default: true) in CMake to use the old GL pipeline version.
Based on the implementation by Matt Bierner:
https://bitbucket.org/mattbierner/ios-aquaria
This changes all typical vector interpolation functions that get
value, time, loopType, pingPong, ease as args from the Lua state;
use unified functions for all value type occurances.
This fixes the slightly annoying problem that it was not possible to
pass a boolean true to pingPong or ease, because lua_tonumber() would
always return 0 in that case.
Also changed:
- obj_getWorldPosition() now takes optional x,y-vector
New:
- obj_getWorldPositionAndRotation() is a more efficient shortcut,
as often both position and rotation are retrieved together,
and the underlying matrix chain operation is rather expensive.
- entity_getEmitter()
- entity_getNumEmitters()
- setSceneColor2()
- getSceneColor2()
GL_CULL_FACE is effectively always disabled, except for quad strip
rendering, and keeping GL_CULL_FACE disabled there does not seem
to cause any visual artifacts.
Instead, it enhances skeletal animation possibilities
(e.g. flipping bone strips over without it disappearing)
Collision rendering is now mapped to Ctrl+Shift+Return instead of capslock.
Also fixed one float->int truncation in script interface,
and removed useless debug message when particle effect "" was supposed
to be spawned (but does never exist).
- Removed some unused member variables.
- The BBGE_BUILD_WIDESCREEN define is now gone.
- Added an TiXMLDocument cache to prevent parsing the same file
once for each entity on the map with the same skeletal.
- Removed Lua func entity_warpToPathStart, which was essentially a no-op
because Entity::followingPath was always NULL. Removed related code.
- Set texture wrap only when required.
(Some changes taken from https://bitbucket.org/mattbierner/ios-aquaria,
special thanks for changeset 72d6460d9e60)