Entities/constraints hierarchy
Posted: Thu Nov 26, 2015 7:01 pm
Hi Norbo,
in what I'm working on these days, I do something like this:
create entity1
create entity2
create entity3
...
create joint ent1-ent2
create joint ent2-ent3
...
and at some point:
Space.Add(entity1)
Space.Add(entity2)
Space.Add(entity3)
...
Space.Add(joint1)
Space.Add(joint2)
...
in a method or another (very close to suspensioncardemo2 for example).
which looks pretty bad and hard to maintain/evolve.
It would be a lot better to have:
Rentity = create_something()
space.Add (Rentity)
where entity will be kind of a root (like in model meshes, a dummy bone transform), which will take care of every entities and joints inside it (also true for debug drawers).
create_something method containing only entities and joints definitions/relationships.
As for now, unless using a data structure (list, array, anything), it's pretty bad to have "part(s) of a part" (example a wheel and a suspension, to a vehicle body) with some elements are added to space inside a method and the "root" element, or base entity added outside.
An example of use: making independent parts which can be used in any way, having an handle to the whole part to add/remove to/from space and drawer would be great.
I would have parts: wheel1, wheel2 (the wheels include "brakes"), suspension, body I can build a vehicle like:
body body
susp susp susp susp or susp susp susp
wheel1 wheel1 wheel2 wheel2 wheel1 wheel1 wheel2
with only one space.add(body).
What do you think ?
in what I'm working on these days, I do something like this:
create entity1
create entity2
create entity3
...
create joint ent1-ent2
create joint ent2-ent3
...
and at some point:
Space.Add(entity1)
Space.Add(entity2)
Space.Add(entity3)
...
Space.Add(joint1)
Space.Add(joint2)
...
in a method or another (very close to suspensioncardemo2 for example).
which looks pretty bad and hard to maintain/evolve.
It would be a lot better to have:
Rentity = create_something()
space.Add (Rentity)
where entity will be kind of a root (like in model meshes, a dummy bone transform), which will take care of every entities and joints inside it (also true for debug drawers).
create_something method containing only entities and joints definitions/relationships.
As for now, unless using a data structure (list, array, anything), it's pretty bad to have "part(s) of a part" (example a wheel and a suspension, to a vehicle body) with some elements are added to space inside a method and the "root" element, or base entity added outside.
An example of use: making independent parts which can be used in any way, having an handle to the whole part to add/remove to/from space and drawer would be great.
I would have parts: wheel1, wheel2 (the wheels include "brakes"), suspension, body I can build a vehicle like:
body body
susp susp susp susp or susp susp susp
wheel1 wheel1 wheel2 wheel2 wheel1 wheel1 wheel2
with only one space.add(body).
What do you think ?