Home
Products
Community
Manuals
Contact
Login or Signup

Box2D and "edges"

BlitzMax Modules Forums/Brucey's Modules/Box2D and "edges"

Brucey(Posted 1+ years ago) #1
There's a new Shape in Box2D called an "Edge". (currently in SVN)
It basically allows you to create complex shapes using multiple connected edges. Take a look at the new examples to see it in action : staticedges, dynamicedges, pyramidstaticedges.

I'm not entirely sure how the use of this new shape affects calculations (compared to a standard polygon shape), as the documentation is sparse at the moment - given that this is a completely new feature.
However, it looks like it will make creating some more interesting shapes a bit easier - especially of the "concave" variety.


Armitage 1982(Posted 1+ years ago) #2
That one is truly excellent !
Now it will be possible to simply many object creation in my project.
Could be very useful to create all sort of interesting level too !
Thanks to add this feature to the module and still closely following the Box2D SVN ;-)


Armitage 1982(Posted 1+ years ago) #3
By the way
Transforming a blitzMax Array into a b2Vec2 array seem's systematic.
Maybe it would be easier to think about a new helper method to transform or directly use blitzMax array instead.

I read somewhere that those kind of edges Chain has effective side.
One side working normally while the other can let dynamic objects pass through.

I'm also wondering if those edges Shapes are more or less quicker in term of calculation speed than a bunch of normal convex polygons.
Could definitely rethink my level editor/loader and reduce by half the number of static shapes !

EDIT
There's a thread on box2d forum with infos on Edges Chain :
http://www.box2d.org/forum/viewtopic.php?f=3&t=1577


Brucey(Posted 1+ years ago) #4
I'm also wondering if those edges Shapes are more or less quicker in term of calculation speed than a bunch of normal convex polygons.

That's what I was wondering too. I haven't seen anything yet which says either way.
Perhaps they'll answer your post :-)

Maybe it would be easier to think about a new helper method to transform or directly use blitzMax array instead.

Possibly... one which expects an array of coordinates. Something for me to ponder...


Rico(Posted 1+ years ago) #5
This sounds good - I will have to download the new version. Thanks Brucey! I


Armitage 1982(Posted 1+ years ago) #6
Working perfectly but I keep receiving various bad references in console when removing them via a DestroyBody()

bad refs:obj=$3c61ab0 refs=$7ffffffe
bad refs:obj=$3ca23b0 refs=$7ffffffe
bad refs:obj=$3c5ed00 refs=$7ffffffe
bad refs:obj=$3c5e390 refs=$7ffffffe


Only one per destruction !

Maybe the last edge via SetIsALoop(true) missing ?
By the way, I suppose that the default value in SetIsALoop() is True right ?


Armitage 1982(Posted 1+ years ago) #7
No clues on this ?
Maybe I should ask in the box2d forum.
Don't know since it's only appear to be warnings.


Brucey(Posted 1+ years ago) #8
Do you happen to have a small example of the error?


Armitage 1982(Posted 1+ years ago) #9
Simply add
m_world.DestroyBody(body)

in staticedges.bmx before Return Self at the bottom of the example file.

It's only happening while destroying bodies so maybe it's a forgotten warning ?
This is trivial since it won't affect the runtime.


Brucey(Posted 1+ years ago) #10
Seems the problem is that multiple edge shapes are being created internally, but reference only a single blitz shape object - which kind of sucks.
So, when it comes to destroy them, the clean-up code attempts to Release the same blitzmax object "more than once".
Looks like i'll need to add some special logic somewhere to counter this. Maybe also ask on the box2d forum to see if he has a better way around this issue.


Brucey(Posted 1+ years ago) #11
Have updated the module to make it create a BlitzMax shape for each edge shape that is internally created by box2d, so that when a body is destroyed, each shape has a reference to an individual BlitzMax object - rather than sharing the same.


Armitage 1982(Posted 1+ years ago) #12
Cool
Isn't this "less efficient and slightly less robust at continuous physics" as spoted in the main Edges topic http://www.box2d.org/forum/viewtopic.php?f=3&t=1577
3th notes ?
Maybe shapes and edges vertices are unrelated after all ? Dunno... But for me it's still ok :)