Jump to content
• Advertisement

# soo how to deal with multiple collision (sphere collides with more than 1 poly)

This topic is 1508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

I search for any information that could help me with this issue, whenever i get multiple collision it only acts on one poly.

Sphere moves from point A to B.

What i have for now:

function that returns whatever i collided with a poly (when yes it returns additionally: new_position of a sphere (after collision with that polygon,

collision normal (the direction from collision point to new sphere pos), collision vector vector from collision point to new sphere pos)

after that it adds this data to the stack (actualy its an array of results)

Function finds all polygons that sphere must collide with.

then i sort the data with forumla

get distance from (new_position and A)

so the smallest distance is first and greatest is last

then i set sphere pos to the first new_position, after that i add all collision vectors from other polygons (btw this is one of my last inventions)

sphere acts like its only the first collision and no others.

#### Share this post

##### Share on other sites
Advertisement

First: I'm not sure I understand everything your various functions do.

However, it appears like you're coding a collision engine combined with a physics engine. If so, you must decide how you want the sphere to behave when it has one or more collisions.

Can you describe in words what the desired result is when the sphere has collisions? You've described what your code does, what (apparently, but that's not clear) you don't want the results to be, but you don't describe what you want the code to do. That is, what are the conditions the new sphere position must satisfy with regard to point A, point B and the various collision data?

Edited by Buckeye

#### Share this post

##### Share on other sites

crap! it seems today its acting differently (maybe becasue of lower fps when i was recording it)

Now i see the collision that occurs for two polys but its not ideal heres a video:

Edited by WiredCat

#### Share this post

##### Share on other sites

Some kind of glitch lets your very small body tunnel through the wall. Given the explanation in the first post, the glitch is likely to be that you ignore the wall because the other wall somehow "takes precedence" or that you compute, and don't check, wrong movements.

Computing multiple collisions given the trajectory the sphere would keep without obstacles makes no sense: after the first collision it bounces and spins and/or it starts sliding or rolling, and successive collisions need to be computed from this new trajectory.

#### Share this post

##### Share on other sites

In my experience you just handle each surface independently - taking the sphere and pushing it back out along the surface normal until it's no longer penetrating the plane. Once this is done for all planes/polys the sphere is intersecting it will no longer be intersecting any of them. This only works so long as the sphere is not touching the edge of the polygon, which is a different scenario where you find the closest point on the edge line.

#### Share this post

##### Share on other sites

i just tried something like that



tcollision_sphere_response_packet res 	= collisionfunc(oldpos, nowpos, model, radius, faceI, faces_len);

tcollision_sphere_response_packet res2 	= collisionfunc(res.NEW_POS, nowpos, model, radius, faceI, faces_len);

tcollision_sphere_response_packet res3 	= collisionfunc(res2.NEW_POS, nowpos, model, radius, faceI, faces_len);



where nowpos is a point where sphere wants to go (old pos is ray start point) function returns NEW_POS - corrected position after sphere collision

my question is is that a correct way to determine further collisions?

EDIT:

radioteeth  one poly sphere collision is not a problem, i have isses determinating proper collision order somehow for slower speeds it only sees one face instead of multiple

for now i'm checking for closest collision with a formula of distance between NEW_POS and ray start point



DYSTANS_CLIP = 10000000000.0f;
for (i = 0; i <= cSTACK_INDEX; i++)

if ( n3ddistance( COLLISION_STACK_RESULT[i],oldpos) < DYSTANS_CLIP )
{
DYSTANS_CLIP  = n3ddistance( COLLISION_STACK_RESULT[i], oldpos);
DYSTANSi_CLIP = i;
}
COLLISION_STACK_CLOSEST_INDEX = DYSTANSi_CLIP;



if the answer is yes (for the first piece of code, and for second too ) then i can actually focus on different things that could solve my problem

Edited by WiredCat

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5
khawk
11
• Advertisement

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013301
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!