Sign in to follow this  

Need help, verlet and colisions with bounding box

This topic is 4693 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

Hello. I've got my whole system working fine, however there is a problem with the colisions. What I'm trying to do is just some basic string system collisions with the screen ("bounding box"). It seems to work but not quite. This is what my collision code looks like:
	float x,y;
	Vector v;
	int j;
	for ( j=0; j<iParticles;j++) {
		tParticle *p1;
        p1 = particles[j];

		x = p1->m_x.x;
		y = p1->m_x.y;

		if ( x <= 0 || x >= SCREEN_W - 1) {
			v = p1->m_x - p1->m_oldx;
			v.x *= -1;
			p1->m_oldx = p1->m_x - v;
		}

		if (y <= 0 || y >= SCREEN_H - 1) {
			v = p1->m_x - p1->m_oldx;
			v.y *= -1;
			p1->m_oldx = p1->m_x - v;
		}
However when a only one particle within a system collides the particle starts jumping and "gets stuck" in the wall. You can see the attached exe http://s3.youshareit.com/download.php?03cae6ed449f4ad83e3a7815e48dadd5 (Scanned with AVG Free) I will be very greatful if anyone can help me Thanks in advance! PS: If anyone can suggest me an article about verlet integration and collision that would be awesome too!

Share this post


Link to post
Share on other sites
classic case. try with adding


if ( (x <= 0 && v.x =< 0) || (x >= SCREEN_W - 1 && v.x >= 0))
{

v = p1->m_x - p1->m_oldx;

v.x *= -1;

p1->m_oldx = p1->m_x - v;
}




same for y.

as for collisions and verlet stuff, try
car
balls

Share this post


Link to post
Share on other sites

This topic is 4693 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this