beastie - Header only collision detection library for Ogre

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

beastie - Header only collision detection library for Ogre

Post by betajaen »

Image

Crivvens! What is Beastie?

Beastie is a C++ based simplified collision detection library for the Ogre3D
graphics engine, and it is neatly packaged in a single header, beastie.h.

"Beastie" should be always pronounced in a Glaswegian accent.

It only detects collisions and does not respond to them as you would typically
encounter in a more fully featured physics engine or more advanced collision
library.

However the detections are accurate and are optimised, building some response
code on top of beastie shouldn't be to difficult, an example of some of this
is in the "beastie.example.cpp" test application that can be found at the beastie
Git repository.

Beastie only uses Ogre as a dependency, and is developed with Ogre 1.7 in mind;
but should work with any 1.x version.

Beastie is released under the MIT licence.

Gessa Download!

Beastie only comes in one file "beastie.h", alternatively a complete Sample may be downloaded.

Beastie is hosted and versioned by GitHub.

Further Documentation and information can be found there.

Awayan'boilyirheid

Beastie is very simple to use, and requires the minimal amount of code to setup.

For example; this is how you would raycasting:

Code: Select all

beastie::collision_tree tree = OGRE_NEW collision_tree();

tree->createNode("tudorhouse.mesh", Ogre::Vector3(0,550,0);
ray_query result;
line ln(Ogre::Vector3(0,25000,0), Ogre::Vector3(0,-1,0), 25000);
tree->intersect(ln, result);

Additionally Beastie comes with an example application, using the OgreBites sample
framework.

The example is a self-installing-when-compiled Ogre Sample. Simply compile the Sample
(in the visual studio directory) and it will copy itself and self-install it self into your Ogre
Samples folder. Run the SampleBrowser application and you'll find "Beastie Example" under
the "Collision Detection" section

Smashin-intit

Beastie will be worked upon the future. My rough To-do list is as follows:

- Bug fixes.
- Box v.s. Box and Plane intersection.
- Further optimisation of raycasting.
- Jacmoe has convinced me to incorporate the works of Paul Nettle; more specifically the
ellipsoid character controller.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: beastie - Header only collision detection library for Og

Post by mkultra333 »

Sounds really interesting. Can it handle collisions against any arbitrary mesh or disjointed triangle soup? (Not that I really need collisions against disjointed triangle soups, I'm just curious.) Can you do a mesh-mesh collisions?
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: beastie - Header only collision detection library for Og

Post by boyamer »

Very nice project,can't wait to give a look to it.

Nice work betajaen
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: beastie - Header only collision detection library for Og

Post by betajaen »

mkultra333 wrote:Sounds really interesting. Can it handle collisions against any arbitrary mesh or disjointed triangle soup? (Not that I really need collisions against disjointed triangle soups, I'm just curious.) Can you do a mesh-mesh collisions?
Nope; No mesh v.s. mesh collisions, I'm afraid. It would be too difficult to implement and very slow to run.

It's more rays v.s. meshes/boxes/planes at the moment.
User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain
x 87

Re: beastie - Header only collision detection library for Og

Post by Xavyiy »

Very nice betajaen =)

I think this little library will be a really useful for a wide range of people, specially people who is starting in 3D programing and even experienced users that wants a simple, but robust, collision detection library for little demos!
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: beastie - Header only collision detection library for Og

Post by AshMcConnell »

LOL @ Awayan'boilyirheid

Looks great, should be useful to a lot of people!

All the best,
Ash
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Re: beastie - Header only collision detection library for Og

Post by sinbad »

Is there anything betajaen can't fit into a single header file? ;)

Nice work mate.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: beastie - Header only collision detection library for Og

Post by Klaim »

Seems a useful tool for not-needing-physic-lib projects! :D
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: beastie - Header only collision detection library for Og

Post by jacmoe »

Like I said to Betajaen earlier: this is great! :)

Since OgreOpcode does do soup versus soup collision detection, maybe the two could be combined?
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: beastie - Header only collision detection library for Og

Post by betajaen »

I'm probably going to leave mesh v.s. mesh collisions to last. It is possible, but I'm really concerned about performance. I mean PhysX is based upon OpCode, but it doesn't do mesh v.s. mesh collisions.

What I may do is do allow very simple convex/concave hull collisions with vertices less than 16, but I want to do OBB boxes and that character controller first.
User avatar
Ruud v A
Gremlin
Posts: 150
Joined: Mon Jan 28, 2008 6:44 pm
Location: The Netherlands
x 5
Contact:

Re: beastie - Header only collision detection library for Og

Post by Ruud v A »

One question:
betajaen wrote: "Beastie" should be always pronounced in a Glaswegian accent.
How is that? I am a non-native speaker so an example would be appreciated :)

It looks great, especially the single header file! No mess, just one include and it works. I like it.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: beastie - Header only collision detection library for Og

Post by AshMcConnell »

Ruud v A wrote:One question:
betajaen wrote: "Beastie" should be always pronounced in a Glaswegian accent.
How is that? I am a non-native speaker so an example would be appreciated :)

It looks great, especially the single header file! No mess, just one include and it works. I like it.
BeeeeStaaaay :D
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: beastie - Header only collision detection library for Og

Post by betajaen »

AshMcConnell wrote:BeeeeStaaaay :D
http://www.youtube.com/watch?v=Nrmcxa1yBec
User avatar
Ruud v A
Gremlin
Posts: 150
Joined: Mon Jan 28, 2008 6:44 pm
Location: The Netherlands
x 5
Contact:

Re: beastie - Header only collision detection library for Og

Post by Ruud v A »

AshMcConnell wrote:BeeeeStaaaay :D
Ah, thanks!
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: beastie - Header only collision detection library for Og

Post by betajaen »

New commit
Changes:

- Added set origin, direction and length functions in line
- Added alternative Raycasting algorithm
The new ray casting algorithm is an adapted version Tomas Möller's "Fast Minimum Storage Ray-Triangle Intersection" which is used in Opcode and possibly PhysX.
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 218
Contact:

Re: beastie - Header only collision detection library for Og

Post by Jabberwocky »

cool stuff.
Image
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: beastie - Header only collision detection library for Og

Post by jacmoe »

This is coolness! :)

Makes me resurrect OgreOpcode again...
Would be interesting to benchmark the two.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: beastie - Header only collision detection library for Og

Post by jacmoe »

But first:
A character controller demo. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: beastie - Header only collision detection library for Og

Post by betajaen »

jacmoe wrote:Would be interesting to benchmark the two.
I did some basic benchmarking.

Using the TudorDemo and in clicking in nowhere particular. I timed each ray cast, then I collected them and got an average.

The adapted Ogre raycasting code takes 45μs
The adapted Opcode/PhysX code takes 50μs

I am surprised about the second, considering how simpler the code is.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: beastie - Header only collision detection library for Og

Post by jacmoe »

I don't give a lot of credits to that kind of benchmarking..

Look to the CDTestFramework which ships with Bullet, if you want good benchmarks. :)

Would be cool to throw in a Beastie example.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Shadow007
Gremlin
Posts: 185
Joined: Sat May 07, 2005 3:27 pm

Re: beastie - Header only collision detection library for Og

Post by Shadow007 »

Great work Betajaen ! One question though :
Looking at your code, I see that you based a 1 axis split submesh computation/splitting on the Y axis ... Is there any reason to stop there and not subdivide further, or simply cut with all 3 axes giving 8 submeshes ?
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Re: beastie - Header only collision detection library for Og

Post by betajaen »

Shadow007 wrote:Looking at your code, I see that you based a 1 axis split submesh computation/splitting on the Y axis ... Is there any reason to stop there and not subdivide further, or simply cut with all 3 axes giving 8 submeshes ?
I wanted to see if it made any difference, and it does a bit.

I'm taking a different approach now and making the meshes part of the octtree directly, rather represented as whole by an AABB. That should skip over some existing code and same on some time on finding the proper mesh fragment for raycasting.
kneeride
Bugbear
Posts: 807
Joined: Sun May 14, 2006 2:24 pm
Location: Melbourne, Australia

Re: beastie - Header only collision detection library for Og

Post by kneeride »

betajaen you rock!! This is very cool.

I've been reluctant to integrate a physics engine because it would have been overkill for what I need. I also thought the memory would be overkill because there needs to be 2 scene managers (1 for phsyics and 1 for ogre).

I've been using MOC for ray to mesh but I'm really hanging out for this one:

>> Box v.s. Box and Plane intersection.

Can you please also consider: Box vs Sphere :-)
User avatar
Matheus Martino
Gremlin
Posts: 164
Joined: Mon Sep 07, 2009 10:44 pm
Location: Brazil
Contact:

Re: beastie - Header only collision detection library for Og

Post by Matheus Martino »

I think betajaen expect you to define a box around your sphere.
Excuse me if my english fail!
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: beastie - Header only collision detection library for Og

Post by Zonder »

doing a box -> sphere check is only a matter of checking to see if a points distance from the center of the sphere is below it's radius
There are 10 types of people in the world: Those who understand binary, and those who don't...
Post Reply