This behavior caused a double free.
Before when we duplicated an instance of a group the new instance keep the pointer of the group but was not added in the group instance list (normal).
And during the object deletion we tried to remove the object in the instance list but anyways if it failed decrement the reference count.
Set the group and the instance list to NULL in ProcessReplica avoid these kind of problems.
Bug introduced in 583fa7d1e, KX_GameObject.setActionFrame can make BL_Action::m_starttime negative. But in BL_Action::Update m_starttime is set to the current time if it's negative.
To fix it we use a boolean BL_Action::m_initializedTime to know if we should initialize the time in BL_Action::Update, it's more stable than comparing times.
Tested with bug task T45945 and T32054, with an extra patch about to fix suspend resume scene issues with actions : D1569
This patch makes independant the override camera zoom and the default camera object zoom. The override zoom is 2.0f and the camera object zoom is computed with the RegionView3D camera zoom.
These features are only used for the embedded BGE, so there's no compatibility issues with the blenderplayer.
I let the override zoom with a setter to allow later to create an override camera in blenderplayer easily.
Tested with the 3 framing modes in embedded and standalone.
I made this patch to declared a python list without converting all elements in python object (too slow) or use a CListValue which required CValue items (too expensive in memory). In the case of a big list of points like a collision contacts points list, to use a CListValue we must implement a new class based on CValue for 3D vector to create a python proxy even if mathutils do it perfectly, we must also convert all points (frequently ~100 points) when fill the CListValue even if the list is not used (in the case of the collision callback). The easy way is to use callback (it doesn't worth to do an inheritance) which convert the item in PyObject only during an acces.
5 callbacks are used :
- Check if the list is valid = allow acces (like PyObjectPlus.invalid)
- Get the list size
- Get an item in the list by index.
- Get an item name in the list by index (used for operator `list["name"]`)
- Set an item in the list at the index position.
All of these callback take as first argument the client instance.
Why do we use a void * for the client instance ? : In KX_PythonInitTypes.cpp we have to initialize each python inherited class, if we use a template (the only other way) we must add this class each time we use a new type with in KX_PythonInitTypes.cpp
To check if the list can be accessed from python by the user, we check if the python proxy, which is the `m_base` member, is still a valid proxy like in PyObjectPlus. But we can use a callback for more control of user access (e.g a list of collision point invalidate a frame later, in this case no real python owner).
This python list is easily defined with :
```
CPythonCallBackList(
void *client, // The client instance
PyObject *base, // The python instance which owned this list, used to know if the list is valid (like in KX_PythonSeq)
bool (*checkValid)(void *), // A callback to check if this list is till valid (optional)
int (*getSize)(void *), // A callback to get size
PyObject *(*getItem)(void *, int), // A callback to get an item
const char *(*getItemName)(void *, int), // A callback to get an item name (optional) use for acces by string key
bool (*setItem)(void *, int, PyObject *) // A callback to set an item (optional)
)
```
To show its usecase i replaced the odd KX_PythonSeq, it modify KX_Gameobject.sensors/controllers/actuators, SCA_IController.sensors/actuators and BL_ArmatureObject.constraints/channels.
Example : {F245193}, See message in console, press R to erase the object and see invalid proxy error message.
Reviewers: brita_, #game_python, youle, campbellbarton, moguri, agoose77, sergey
Reviewed By: campbellbarton, moguri, agoose77, sergey
Subscribers: sergey
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1363
This patch fixes:
- the call of LibFree on a unfinished loaded library;
- memory leak created on end of game : the async libraries are loaded but not converted, so not freed with the master scene.
Reviewers: campbellbarton, sybren, youle, hg1, moguri, lordloki
Reviewed By: moguri, lordloki
Differential Revision: https://developer.blender.org/D1571
It fix T46381. Normally BL_Action::Update (manage action time, end, loop…) should be called the same number of times as BL_Action::UpdateIPO (update action position, scale ect… in the game object).
But the bug report shows that UpdateIPO is called one less time than Update. To fix it i revert the commit 362b25b38287cb75e4d22b30bdbc7f47e8eb3fdf and implement a mutex in BL_Action::Update.
Example file : {F245823}
Reviewers: lordloki, kupoman, campbellbarton, youle, moguri, sybren
Reviewed By: youle, moguri, sybren
Maniphest Tasks: T39928, T46381
Differential Revision: https://developer.blender.org/D1562
Change the mathutils callback from vector to color for mistColor, backgroundColor and ambientColor.
Reviewers: lordloki, campbellbarton, panzergame, moguri, sybren
Reviewed By: panzergame, moguri, sybren
Projects: #game_engine, #game_logic
Differential Revision: https://developer.blender.org/D1432
Actually we only have a Python API that allows to change the max jumps value.
The patch also allows non programmers to change the maximum numbers of jumps.
Reviewers: panzergame, sybren, campbellbarton, lordloki, moguri, agoose77
Reviewed By: lordloki, moguri
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1302
* Change the character jumping variables and methods from int to char.
* Limit the maxJumps integer value from 0 to 255.
* Allow to set the minimum jump amount to 0.
Reviewers: panzergame, lordloki, moguri
Reviewed By: lordloki, moguri
Subscribers: agoose77
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1305
This patch will delete all associated objects from a group instance (dupli group) if the are deleted.
Reviewers: brita_, sybren, lordloki, moguri
Reviewed By: lordloki, moguri
Projects: #game_engine
Maniphest Tasks: T36388
Differential Revision: https://developer.blender.org/D1205
Extending the existing game actuator with a screenshot function, to give also non programmers the ability to take screenshots in the BGE.
Reviewers: lordloki, campbellbarton, moguri
Reviewed By: lordloki, moguri
Subscribers: lordloki, Genome36
Projects: #game_engine
Differential Revision: https://developer.blender.org/D651
I have removed the m_pHitObject, m_xray and m_testPropName and replace them by a temporary struct "RayCastData" which contains these datas and a collision mask. Finally i add a collision mask argument in the python function "rayCast" :
```
rayCast(to, from, dist, prop, face, xray, poly, mask)
```
It can be useful to hit only object which are on the right colision layer. for example if you have hitbox for a charater or vehicle you don't want to hit it with raycast.
test file : {F237337}
left mouse click on two planes and see console messages.
Somewhat more elaborate test file by @sybren: {F237779}
Look around and click on the cubes. One cube lamp responds, the other doesn't, based on their collision groups.
Reviewers: moguri, hg1, agoose77, campbellbarton, sybren
Reviewed By: agoose77, campbellbarton, sybren
Subscribers: campbellbarton, sergey, blueprintrandom, sybren
Projects: #game_engine, #game_physics
Differential Revision: https://developer.blender.org/D1239
We now keep actions around when they are finished playing so scripts can
still get access to information such as the current frame. Playing a new
action in the same layer still overwrites the previous action as before this
commit. Using an explicit KX_GameObject.stopAction() will free the memory. The
action is also freed when the KX_GameObject is freed as before.
By using getAnimRecordFrame(), game developers have access to the frame
number used by the "Record animation" feature. This enables them to
record additional information in Blender's F-Curves and ensuring perfect
synchronization with the information already recorded by Blender.
The setAnimRecordFrame() can be used to change the frame number at which
animations are recorded, for example to introduce delays the recording that
do not require delays in the actual game/simulation run.
The getter/setter functions in KX_KetsjiEngine are not directly named after
property they access (m_currentFrame). I found "current frame" to be too
vague for a public interface, hence chose a more descriptive name.
Reviewers: moguri, hg1, campbellbarton, panzergame, aligorith
Reviewed By: panzergame, aligorith
Differential Revision: https://developer.blender.org/D1449
Fixing crash if the physic type is set sensor or character. Caused by a790e172d0281e64.
Fixing memory leak, if the constraint is deleted with Python API removeConstraint().
Add RemoveConstraint() method to avoid code duplication.
Rename old RemoveConstraint() to RemoveConstraintById() which is more suitable name for this method.
The issue was caused by the following construction:
def = env['SOMETHING']
defs.append('SOMETHING_MORE')
Since first assignment was actually referencing environment option it was totally
polluted hawing weird and wonderful side effects on all other areas of Blender.
It works similar to getActionFrame(), you have to give a layer or not (for layer 0) as the argument and it returns the name of the animation that the object is currently playing.
Example:
```
import bge
own = bge.logic.getCurrentController().owner
own.playAction("SomeAction",0,20)
print(own.getActionName())
```
>> SomeAction
Here is an example file, just open the blend file with the terminal opened
and press P, you can see how the current animation is being printed:
{F217484}
Reviewers: moguri, hg1, panzergame, campbellbarton
Reviewed By: panzergame
Subscribers: campbellbarton, hg1, #game_engine
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1443
- rename WITH_EXTERNAL_AUDASPACE to WITH_SYSTEM_AUDASPACE.
- rename C/PYAUDASPACE to AUDASPACE_C/PY
- simplifying cmake defines and includes.
- fixing include paths and enabling WITH_SYSTEM_AUDASPACE for windows.
- fixing scons building.
- other minor build system fixes.
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
Actually for the the amount of GLSL textures units is limited by the amount of multitexture units (GL_MAX_TEXTURE_UNITS_ARB).
Most of the Nvidia graphic cards supports only 4 multitexture units, so Nvidia users can not use more then 4 GLSL textures for a custom shader.
This patch removes this limitation by using GL_MAX_TEXTURE_IMAGE_UNITS_ARB if GLSL is supported, but still limit the amount to the maximum texture limit of 8.
Reviewers: lordloki, agoose77, danielstokes, panzergame, sybren, moguri
Reviewed By: panzergame, sybren, moguri
Projects: #game_engine, #game_rendering
Maniphest Tasks: T37074
Differential Revision: https://developer.blender.org/D1389
This commit contains all the remained parts needed for initial integration of
OpenSubdiv into Blender's subdivision surface code. Includes both GPU and CPU
backends which works in the following way:
- When SubSurf modifier is the last in the modifiers stack then GPU pipeline
of OpenSubdiv is used, making viewport performance as fast as possible.
This also requires graphscard with GLSL 1.5 support. If this requirement is
not met, then no GPU pipeline is used at all.
- If SubSurf is not a last modifier or if DerivesMesh is being evaluated for
rendering then CPU limit evaluation API from OpenSubdiv is used. This only
replaces the legacy evaluation code from CCGSubSurf_legacy, but keeps CCG
structures exactly the same as they used to be for ages now.
This integration is fully covered with ifdef and not enabled by default
because there are several TODOs to be solved first:
- Face varying data interpolation is not really cleanly implemented for GPU
in OpenSubdiv 3.0. It is also not implemented for limit evaluation API.
This basically means we'll have really hard time supporting UVs.
- Limit evaluation only works with adaptivly subdivided meshes so far, which
basically means all the points of CCG are pushed to the limit. This gives
different result from old code.
- There are some serious optimizations possible on the topology refiner
creation, which would speed up initial OpenSubdiv mesh creation.
- There are some hardcoded asumptions in the GPU and DerivedMesh areas which
could be generalized.
That's something where Antony and Campbell can help, making it so the code
is structured in a way which is reusable by all planned viewport projects.
- There are also some workarounds in the dependency graph to make sure OpenGL
buffers are only freed from the main thread.
Those who'll be wanting to make experiments with this code should grab dev
branch (NOT master) from
https://github.com/Nazg-Gul/OpenSubdiv/tree/dev
There are some patches applied in there which we're working on on getting
into upstream.
Revert "BGE: Cleanup : merge 3 loop in 1 in function DupliGroupRecurse."
This reverts commit 371e5f25a054759014efa27c6fe4d497854ed64e.
The fix is basically to revert the cleanup commit 371e5f25 (and 3d658bf7)
Also 5dc22fbbf had to be adapted to the reverted code.
Conflicts:
source/gameengine/Ketsji/KX_Scene.cpp
With this patch "Particle Info" node from Cycles works in GLSL and BI
Alexander (Blend4Web Team)
Reviewers: psy-fi
Note: moved particle info to object render instance instead of
shadeinput during review - Antony.
Differential Revision: https://developer.blender.org/D1313
ImBuf types were getting stored as bitflags in a 32bit integer which had
already run out of space. Solved the problem by separating file type to
an ftype enum, and file specific options to foptions.
Reviewed by Campbell, thanks a lot!
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
The camera-aiming code was using a near-zero-length cross product, which
caused oscillations. Thresholding on the cross product length seems to
fix this.
Reviewers: lucky3, Matpi, lordloki
Reviewed By: lordloki
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1387
Add support for material diffuse, specular… in KX_BlenderMaterial python proxy. And use mathutils in KX_BlenderMaterial for the specular and diffuse color in KX_BlenderMaterial.
Reviewers: sybren, brita_, kupoman, agoose77, dfelinto, moguri, campbellbarton, hg1
Reviewed By: moguri, campbellbarton, hg1
Subscribers: dfelinto
Projects: #game_engine
Differential Revision: https://developer.blender.org/D1298