Ray Cast Terrain

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
BoltonBeedz
Posts: 45
Joined: Fri Dec 07, 2007 12:58 am

Ray Cast Terrain

Post by BoltonBeedz »

Hi again. How are you?
i think i've got a bug or rounding issue on terrain. heres the gist of my code.

Code: Select all

        public static RayResult terrainray(Ray r, RayCastableContainerWithoutMargins terrain)
        {
            RayResult result = RayResult.Zero;
            terrain.rayCast(r.Position, r.Direction, 10000, 
                out result.hitEntity, out result.CollisionPos, 
                out result.normal, out result.time);

            //CONVERT NORMAL TO DECAL MATRIX
            result.CollisionMatrix = Matrix.Invert(Matrix.CreateLookAt(
                Vector3.Zero, result.normal, 
                new Vector3(1,0.9f,1))) 
                * Matrix.CreateTranslation(result.CollisionPos);

            return result;
        }
i'm putting a bullet hole onto a StaticTriangleGroup using this but the terrain doesn't work.
It just returns a non-collision
result.CollisionPos = {X:-3.402823E+38 Y:-3.402823E+38 Z:-3.402823E+38}
result.time = -9999.0
any ideas?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Ray Cast Terrain

Post by Norbo »

I'm unable to replicate the issue in v0.10.1. Does the terrain's position and ray's data match what you expect from the graphics?
Post Reply