Advertisement Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


Well I was thinking, about my problem. Yeah that one, in the last post. So I guess I just had to get out the old pen and paper, and try to do what I think it should be doing. The problem was, the original formula I got the math from, called for the param planeD. Which was described as "planeD; // p * planeNormal = planeD". And you should know by now that p = wtf?! to me. So I was trying to find something I thought p should be, so I threw in the sphere center. Things wernt working, I would debug to see that things were being tested inverted. So I reversed the cases, and poked at this and flipped that. And it did work, but only when the sphere had the exact inverted direction as the plane. And that means that it would go past the plane sometimes before thinking it hit. Pretty easy to see, because I made the sphere-plane collision cause a deletion of the spheres node. I like it. I got to test my collision code, and my linked list 'random' node deletion. Joy.

But I know you are really just here because I post alot of code, so drink up!

bool CColSphere::TestPlane(const CColPlane &s, float tcount)
// the distance from this spheres center point
// to the planes center point. dot product to get
// distance in planes normal direction.
float d = (s.Direction * (s.Internal - Internal));

if(d <= -Radius) // on backside on planes normal?
return false; // dont test the back

// move it for this time frame and test to see if
// we are now less than the spheres radius distance
// sphere to plane on planes normal.
Vector3 moving = (Direction * (Velocity / (1.0f / tcount)));
Vector3 test = moving+Internal;
d = (s.Direction * (s.Internal - test));

if(d >= Radius) // still 'in-front'
return false; // no hit

return true; // went from, in-front to (atleast) into plane

Next test on the list is going to be the planes with/heigh check. Should be a sinch, but dont worry, I'll screw it up.
Sign in to follow this  


Recommended Comments

There are no comments to display.

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
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!