Log In
New Account
Home My Page Projects Blender 2.x BF release
Summary Activity Tracker SCM Files

Patches: Browse

[#31442] API improvements: Group references python api, for better control over groups and instances

Date:
2012-05-13 10:07
Priority:
3
State:
Closed
Submitted by:
Martin Sell (moerdn)
Assigned to:
Campbell Barton (campbellbarton)
Category:
Game engine
Group:
None
Resolution(Old, use status):
New
Resolution:
Applied
Patch for:
 
Summary:
API improvements: Group references python api, for better control over groups and instances
Detailed description
This patch is an API extension for KX_GameObject class, that allows the user to gain better control over group instances at runtime. At level creation time, the user have to work with empty objects (proxies) for the grouped objects, but at runtime the proxy creates the whole group instances.

The problem:
There is no connection between the group proxy and the instanced objects. The patch provides two new read-only properties for KX_GameObject's, so you can easily access all instanced objects from the group empty, or you can access the group proxy from an instanced object.

For more informations you can checkout the complete proposal:
https://gitorious.org/bge-sandbox/pages/GroupRef

The files for testing this feature and for showing some possibilities:

http://dl.dropbox.com/u/2779060/BGE/group-reference.patch
http://dl.dropbox.com/u/2779060/BGE/group-reference_object_access.blend
http://dl.dropbox.com/u/2779060/BGE/group-reference_parenting.blend
http://dl.dropbox.com/u/2779060/BGE/group-reference_properties.blend

Followup

Message
  • Date: 2012-06-05 02:59
  • Sender: Daniel Stokes
  • I am not sure how you created your patch, but I had to tweak the file a little to get it to apply right.

    More importantly though, if you edit the python API make sure to edit the docs corresponding to that part of the API. This is doable in the appropriate rst file in the doc/python_api folder.
  • Date: 2012-07-29 02:12
  • Sender: Mitchell Stokes
  • There is a memory leak: KX_GameObject::m_pInstanceObjects is never cleaned up.
  • Date: 2012-07-29 02:37
  • Sender: Mitchell Stokes
  • Okay, I've uploaded a version of the patch with better refcounting. Visual Leak Detector is not reporting any more leaks with this version. :)
  • Date: 2012-07-29 02:42
  • Sender: Mitchell Stokes
  • I just noticed that you have added some KX_PYMETHODs in KX_GameObject.h that are never actually getting used, and can be removed.
  • Date: 2012-07-30 01:45
  • Sender: Mitchell Stokes
  • Looks like the improved patch can still cause leaks with replica objects. Some additional processing might have to be done in KX_GameObject::GetReplica().
  • Date: 2012-08-06 20:28
  • Sender: Martin Sell
  • Your patch causes a zombie object for every group proxy, that is deleted.
    I have added a check for group objects in newDeleteObject():
    If the group object is deleted, all members should loose their reference to the group object.

    + if(newobj->GetInstanceObjects()) {
    + for (int i = 0; i < newobj->GetInstanceObjects()->GetCount(); i++) {
    + KX_GameObject* instance = (KX_GameObject*)newobj->GetInstanceObjects()->GetValue(i);
    + instance->RemoveDupliGroupObject();
    + }
    + }

    I still have some stuff to cleanup, an assertion is not needed in RemoveDupliGroupObject() and I will also cleanup the KX_PYMETHODs.
  • Date: 2012-08-06 20:34
  • Sender: Martin Sell
  • Tried to upload, the patch, did not work the first time..
  • Date: 2012-09-17 09:48
  • Sender: Mitchell Stokes
  • I've been using this patch quite a bit in my current game project, and I'm not getting any more zombie objects. I'm attaching the copy of the patch that I've been using. It's mostly the same as Martin's last patch, but I've removed an assert (it was right in front of a NULL check anyways), and I made the patch with TortoiseSVN.

    I'm assigning this to Campbell for final review/okay.
  • Date: 2012-09-19 20:32
  • Sender: Martin Sell
  • Thanks for your support, Mitchell!
  • Date: 2012-10-07 02:10
  • Sender: Mitchell Stokes
  • This patch has now been committed as r51131.

    Congrats on finally getting this into trunk!
 

Attached Files:

Name Date Download
group-reference.patch 2012-05-13 10:07 Download
group-reference-memfixed.patch 2012-07-29 02:37 Download
group-ref-memfix_new.patch 2012-08-06 20:34 Download
group-reference-svn.patch 2012-09-17 09:48 Download

Changes:

Field Old Value Date By
ResolutionOpen2012-10-07 02:10moguri
status_idOpen2012-10-07 02:10moguri
close_dateNone2012-10-07 02:10moguri
File Added22054: group-reference-svn.patch2012-09-17 09:48moguri
assigned_tonone2012-09-17 09:48moguri
File Added21676: group-ref-memfix_new.patch2012-08-06 20:34moerdn
File Added21603: group-reference-memfixed.patch2012-07-29 02:37moguri
File Added20664: group-reference.patch2012-05-13 10:07moerdn