Jump to content


collision response


10 replies to this topic

#1 enjoycrf

    Banned

  • Banned
  • PipPip
  • 52 posts

Posted 08 March 2011 - 09:01 AM

hi
im working some more on my collision
it works by projecting my velocity vector along the collision plane normal
ive limited this to the ground trace only since it work the same all around
the problem is that with each plane change the collision fraction keeps shrinking
meaning i sink further into the ground as the sliding remains fine
so ive added something to push me back out just a bit
but this can surely produce an ugly tail chasing effect
is there a way to get around this

//push up the final amount
if (g_tracer.outputFraction < 0.9f) { 
	VectorAdd(player.n_vel, camera.up, player.n_vel);
}


#2 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 08 March 2011 - 10:50 AM

For The Last Frikkin Time, Use God-damn Code Tags. Why should we bother spending time reading your unreadable posts if you consistently lack the motivation to spend time to make it readable for us?
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#3 enjoycrf

    Banned

  • Banned
  • PipPip
  • 52 posts

Posted 08 March 2011 - 11:56 AM

jolly goblins calamity!
how do i do code tags
crickey

#4 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 08 March 2011 - 11:58 AM

[code]..your code here..[/code] :D
http://www.devmaster...c.php?do=bbcode
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#5 enjoycrf

    Banned

  • Banned
  • PipPip
  • 52 posts

Posted 08 March 2011 - 12:04 PM

and the answer to my quastion braw?! : /

#6 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2718 posts

Posted 08 March 2011 - 12:25 PM

i know the solution, you push back the objects radius its inside the wall, not the velocity of the object.
i have to say your right about using the triangles normal tho.
then guess what, its a sphere triangle collision slider.
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#7 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 08 March 2011 - 12:37 PM

You currently check for a threshold, and when it's below a certain value you add a unit length vector (the camera up). Rather, you should move to a position that is always N units above the surface. So you should calculate penetration depth, and then adjust accordingly.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#8 enjoycrf

    Banned

  • Banned
  • PipPip
  • 52 posts

Posted 08 March 2011 - 08:34 PM

thanx
but i cant push above the surface
it has to stay just barely touching or gravity will try to push back down and create a nasty bouncing effect
ur right about getting the exact distance to push back out tho
that might just be the answer since it only starts to glitch when the numbers dont add up exactly right
i.e. push out too far and glitch
other than that its friken money

---
also
rouncer i want to include your thoughts but i cant quite understand what you mean since u messed up some of your words

---
this seems to work fabulously
note 10 is the length of the collision probe
which is also the radius of the bounding sphere
9 - is to bring it back to 0.9 w out pushing totally out

//push up the final amount
		if (g_tracer.outputFraction < 0.9f) { 

			scale = 9 - (10 * g_tracer.outputFraction);
			
			VectorScale(camera.up, scale, push);
			VectorAdd(player.n_vel, push, player.n_vel);
			
		}

---
this doesnt work so nicely on the wall trace at all

---
ok do u guys know why my collision fraction keeps growing
meaning im being slowly pushed out from the wall while sliding
i now limited it to just this code

//keep going or
	if (trace.outputFraction == 1) return;

	//slide along wall
	PM_ClipVelocity(player.n_vel, trace.outputNormal, player.n_vel, OVERCLIP);

---
ok i managed to hack it with this code
and now there is no bouncing
i guess no one can escape ugly code

//keep going or
	if (trace.outputFraction == 1) return;


	//slide along wall
	PM_ClipVelocity(player.n_vel, trace.outputNormal, player.n_vel, OVERCLIP);
		
		
	//bull back
	if (trace.outputFraction > 0.98) {

		scale = 10 - (10 * trace.outputFraction);
		
		VectorScale(trace.outputNormal, scale, pull);
		VectorSubtract(player.n_vel, pull, player.n_vel);
		
	}
	
	
	return;


#9 enjoycrf

    Banned

  • Banned
  • PipPip
  • 52 posts

Posted 09 March 2011 - 03:17 AM

ok that is so unreadable
whatever

u running out of pixels or something?

#10 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2718 posts

Posted 09 March 2011 - 04:23 AM

Look. just check how far away the sphere is from the wall.

subtract it from radius.

if its a positive amount push back the triangles normal the amount left.

Its that simple.

Your code is crazy, I dont even want to read it, whats this outputfraction bullshit?
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#11 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 09 March 2011 - 10:53 AM

enjoycrf said:

u running out of pixels or something?
Either stick to the netiquette of this forum or be gone.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users