Blitz Collision vs Other Library (Collision only)

Blitz3D Forums/Blitz3D Beginners Area/Blitz Collision vs Other Library (Collision only)

RustyKristi(Posted 2014) [#1]
I recently noticed that other users discussed of having external libs for their collision, Coldet, etc.

Is the default Blitz collision any good, performance wise? Or am I missing something here and need to expand?


Zethrax(Posted 2014) [#2]
The default Blitz collision is pretty good performance wise, but limited in its functionality. It basically uses a spherical collision volume (you can actually use a vertically aligned ellipsoid, but I've never gotten much sense out these) for moving objects and polygonal/axially-aligned bounding box/sphere for the static volumes. Other collision and physics systems may be able to use a variety of shapes (spheres, cylinders, capsules, arbitrarily-oriented boxes, etc) and will usually allow you to combine collision primitives together to create complex compound shapes. You can usually create a convex hull around objects too and use that as a moving collision volume. And then you've got physics based systems that try to emulate real world physics.

Blitz3D's sytem is fast because it's simple. More complex collision systems will be doing a great many more calculations and will be slower as a result. Use whichever works best for whatever you need to achieve. Something else to be aware of is that pretty much any system you use will be optimized to hell and gone, if its any good. Most sort their collision tests using optimized sort trees (I think Blitz3D uses a K-D tree), so you usually don't need to worry about doing these optimizations yourself.

If you want to play around with an alternative collision/physics system then you can find a wrapper for an older version of Newton Dynamics at the link below.

http://www.blitzbasic.com/Community/posts.php?topic=99274

Here's a test project I did using the Newton Dynamics wrapper.

http://www.blitzbasic.com/Community/posts.php?topic=99383


RemiD(Posted 2014) [#3]
Blitz3d collision system works well, don't worry.


will usually allow you to combine collision primitives together to create complex compound shapes


you can do that too with Blitz3d collision system by setting several colliders ellipsoid as childs of a pivot, then turning moving the pivot.
But you will have to destroy and recreate each collider ellipsoid before turning moving each pivot so that it does not get stuck somewhere.
It works well to create a kind of collider capsule for a character.


RustyKristi(Posted 2014) [#4]
Thank you for the info guys. I guess I will be sticking to Blitz built in collision for now.

@Zethrax
Thats a nice FPS engine you got there. keep it up!

@RemiD
Can you give a basic example on how a pivot is used in collisions? I thought of just assigning one directly is enough.


Yasha(Posted 2014) [#5]
Basically the reason people use ColDet and physics engines and others is either because the built-in collision system often winds up being too slow, or because they need something other than sphere colliders.

The performance advantages of other systems are twofold:

- Blitz3D uses a naive world space that tests every object against every other object, which is utterly hopeless for large numbers of colliders; other engines either use more complex space partitioning or allow you to run individual tests between specific objects.

- Blitz3D's polygon collision detection isn't naive, but it isn't hugely optimized either. If you need polygon-level collision detection, ColDet is literally hundreds of times faster in some circumstances. (Don't know the details of how the latter works.)

Most of the important details of how B3D collisions work can be found here and here.


I dispute that Blitz3D is "fast because it's simple", as my experience is that Blitz3D's builtin system is basically the slowest option out there. However, this is not a reason to replace it unless you can confirm that it's actually slowing your program down. Used as intended (a couple of dozen NPCs running around a polygonal environment?), it is more than fast enough for purpose.

Never replace something on performance grounds unless you've confirmed that it's the bottleneck.


The other reason to replace it of course is if it doesn't do what you need; in that case, performance is irrelevant. Since it's only a collision engine, it can't do things like joints and forces, which you need for overrated fashionable modern game features like ragdolling, and for which you need a true physics engine.


_PJ_(Posted 2014) [#6]
Like so many other things, it really depends on the circumstances and what you require the system to 'do'.
The number of entities you may be checkig, the complexity of the collision checks and whether you may be requiring a more coherent 'physics engine' (i.e. to account for elasticity animations and so on) are all deciding factors.

For a low number of simple collision events, it can be perfectly suitable as it is simple and effective and even faster than unnecessary processing for more complete systems.

-

I still find the biggest drawback with the Blitz3D collision system is the lack o fa no-response, where collision is detected but no stoppping/sliding of the collided object should occur.


RemiD(Posted 2014) [#7]

I still find the biggest drawback with the Blitz3D collision system is the lack o fa no-response, where collision is detected but no stoppping/sliding


easy to do : simply destroy and recreate the collider ellispoid before turning moving it so that you can detect collisions without having the collider ellipsoid stuck somewhere.

Oh and by the way, to decrease collisions time, you want to use low tris meshes for the collidables.


RemiD(Posted 2014) [#8]

a basic example on how a pivot is used in collisions?


you need one variable to hold the reference for the root pivot (the entity which you will turn move) and several variables to hold the references of the others pivots (childs) (the colliders ellipsoids which will detect a collision with the collidables)

create the collidables (with low tris meshes)
put each collidable in a collision group (with entitytype())

configure the collisions detection and response between the different collision groups (between colliders ellipsoid and collidables) (with collisions()), i usually use the response stop.

then in the mainloop
delete each child pivot
recreate each pivot
position oriente each pivot depending on the root pivot position orientation (with tformpoint() positionentity() rotateentity())
set each pivot as a child of the root pivot
give a radius to each child pivot (with entityradius())
put each child pivot in a collision group (with entitytype())
turn move the root pivot (with turnentity() movenentity())
calculate the collisions (with updateworld())
check if a collision has happened between a collider ellispoid and a collidable (with countcollisions() and collisionentity())
if yes
reposition reoriente the root pivot depending on the concerned collider ellipsoid position orientation (with tformpoint() positionentity() rotateentity())
update the state of your entity

you can see how to manage simple collision in this code example :
http://www.blitzbasic.com/codearcs/codearcs.php?code=3141