New Collision Idea
#1
Posted 16 March 2008 - 09:32 PM
It uses a Z-buffer idea.
We want to test between two objects.
so we take the direction vector with which object1 is moving. and we construct a matrix which will transform all the points as though the object was 2D and being looked at from this same direction vector. ie as if a viewer is standing right infront of it. we do similar calcs like in software rendering to make a z-buffer. then we stop. Note the width and height of the z-buffer will be mapped to the max size of the largest object, so it does not correspond in any way to the viewport.
Now for the second object. we transform it using a matrix constructed from the same direction vector as object1, the matrix will be different since these two objects are in different positions. we also construct a z-buffer for this object
and we test the two z-buffers to see at which "x and y pixel" they collide.
we can use these x-y pairs to work backwards and find the exact world collision point.
Sound good?
#2
Posted 16 March 2008 - 09:57 PM
#3
Posted 17 March 2008 - 06:53 PM
I'll stick to a simple yet very accurate separating axis test for convex polyhedra, or GJK for general convex objects
-
Currently working on: the 3D engine for Tomb Raider.
#4
Posted 18 March 2008 - 07:32 AM
.oisyn said:
Is this method faster than using plane-plane collision detection?
if so could you point me to some documentation please :)
#5
Posted 18 March 2008 - 10:39 AM
#6
Posted 19 March 2008 - 07:20 AM
#7
Posted 19 March 2008 - 12:37 PM
- www.mattiasgustavsson.com - My blog and current projects
- www.rivtind.com - My Fantasy world and isometric RPG engine
- www.pixieuniversity.com - My Software 2D Game Engine
#8
Posted 21 March 2008 - 04:54 AM
I make a basis that includes both the models in the direction object one is
going, with an orthogonal projection - draw model a in red, model b in green.
draw model b in cw mode then if there is any red in the render, then they
collide?
if thats true i dont see how it would go slow, because its a pretty small
pixel shader and it could go fast...
#9
Posted 21 March 2008 - 05:33 AM
#10
Posted 21 March 2008 - 05:54 AM
what you draw them translucently - and only if red and green are filled they
both filled that pixel?
#11
Posted 21 March 2008 - 06:07 AM
the first render in as a texture in the shader, make the render target 1 pixel,
and check every pixel to every pixel, as soon as you get a depth fail, write 1,1,1,1 to the output pixel.
if its a pass write 0,0,0,0. (nothing)
then grab the 1 pixel from the video card into the system memory(its only 1
pixel, so it should go fast), lock and read.
and you got it. per pixel collision detection. what an awesome idea if you do want to go to that detail.
but if you use the zbuffer or stencil buffer, maybe you avoid crossing the bus.
#12
Posted 21 March 2008 - 10:44 AM
Now think of there being a plane infront of object1 which is the 'location' of our Z-buffer. This will be on the closest pixel of object1.
To do the test we fill our z-buffer with 1's where object1 comes into play.
Then whenever object2 has a pixel that is further away than object1, ie it doesn't overwrite the z-buffer, we mark that pixel as 3. (meaning a collision)
The only problem comes in with penetration depth. since 2 or more pixels of object2 could intersect in the same block as each other in the z-buffer. so we might have to store another array/buffer which holds the minimum z-value whilst our original z-buffer holds the max z-value of our collision.
The major problem that arises is, I may be able to calculate the exact collision point, but then I still have to search for which polygons intersect :(
Does this method have any practical applications or is it just way too slow?
remember that pre sphere-sphere tests help with obvious elimination, but the algorithm is slower for larger objects
#13
Posted 21 March 2008 - 11:13 AM
#14
Posted 21 March 2008 - 04:21 PM
Nyad said:
Try it, then tell us :yes:
- www.mattiasgustavsson.com - My blog and current projects
- www.rivtind.com - My Fantasy world and isometric RPG engine
- www.pixieuniversity.com - My Software 2D Game Engine
#15
Posted 21 March 2008 - 05:25 PM
I tried writing just the part of modifying a buffer of size 1024*768 200times and
it was hitting 230milliseconds to do. which is far too slow if I want to reach anything near 60fps
PS: this was in asm but without mmx/sse123. but if it needs those instructions already at that stage then its too slow to begin with
#16
Posted 22 March 2008 - 02:03 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












