Page MenuHome

BGE: New GetConstraints method
AbandonedPublic

Authored by Thomas Szepe (hg1) on May 26 2015, 6:50 PM.

Details

Summary

This patch adds a new getConstraints method to the Physics Constraints (bge.constraints) API (updated version of my old patch).
The method returns a tuple list of constrain wrappers, for constraints that are generated within Blender and the API.
The patch also fix the constrain memory leak.

Actually I am not satisfied with the actual patch.

  1. The patch is a way to complicated. I will try to improve it.
  2. Constraints that are deleted via API are not modifies the constraint list and so the wrapper still returns deleted constraint wrappers.
  3. The Python API method it self. I think a returning a dictionaries with the target object/name or a method which where the user can give target object/name would be better.

Diff Detail

Event Timeline

doc/python_api/rst/bge.constraints.rst
70

Why not use something like : KX_GameObject.physicsConstraints ?

source/gameengine/Physics/Bullet/CcdPhysicsController.h
60

We are in C++ you can create a class with a useful constructor.

490

Can you add a btTypeConstraint variable in ConstraintData to merge the list m_ccdConstraintRefs and m_CcdConstraintTargetDatas ?

534

It can be simplify if you use only one list for constraints.

source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
545

delte, delted -> delete, deleted

555

delte, same as above

Thomas Szepe (hg1) marked 2 inline comments as done.May 26 2015, 8:15 PM
Thomas Szepe (hg1) added inline comments.
doc/python_api/rst/bge.constraints.rst
70

Physics Constraints (bge.constraints) is a own module and the KX_GameObject never returning a wrapper.
So I keep it consisted with the other wrapper API like character and vehicle wrapper.
I leave this open for discussion.

More interesting for me now would be, that I get answer the third point (in summary) that is related to it.

source/gameengine/Physics/Bullet/CcdPhysicsController.h
60

Basically there is not much difference in the using a class or a typedef struct. Both has a constructor. As long I only need store data and don't need any method, I prefer to use a struct instead of a class. So it is clearly visible that it is a simply a data storage.
So actually I don't see any reason (not for now) to use a class.
I have an idea to simplify the patch, if it works I don't need the struct/class any more.

490

Same a below. I need two lists to identify main and target object.

534

That does not work. In my previous patch I had a single list. But I need to split it into two, because I only want to return the constraints that are assigned to this object. I don't want to get the constraints that are pointing to this object too.

source/gameengine/Physics/Bullet/CcdPhysicsController.h
534

When you create a constraint the owner is the A object in the constraint, right ?

I came across this Differential/Patch while trying to figure out who to add as reviewers for a diff/patch I made for bug report T38448 (BGE bullet physics constraint memory leak).

Am I correct in saying that the ConstraintData struct and the added methods are only there to track what's pointing to a constraint so that when the constraint is removed everything that points to it can be told it no longer exists?

Looking over this diff and getting a broader view of the code I think I have a simpler solution to the constraint memory leak bug than my original solution. Is it ok if I look into it a bit further, create a diff and put you active (on this diff) people (hg1, panzergame & lordloki) as reviewers?

My apologies if my terminology isn't quite right.

Is it ok if I look into it a bit further, create a diff and put you active (on this diff) people (hg1, panzergame & lordloki) as reviewers?

i'm agree if it's a short fix.

Am I correct in saying that the ConstraintData struct and the added methods are only there to track what's pointing to a constraint so that when the constraint is removed everything that points to it can be told it no longer exists?

It is used for this too. But it is also used to get the constraints list back (new GetConstraints() method) form the object where the constraint is assigned.

Looking over this diff and getting a broader view of the code I think I have a simpler solution to the constraint memory leak bug than my original solution. Is it ok if I look into it a bit further, create a diff and put you active (on this diff) people (hg1, panzergame & lordloki) as reviewers?

Yes, of course.

BGE was removed in Blender 2.80 this patch is being closed as a result.