A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Julio Jerez » Sun Sep 11, 2011 5:54 pm
The function was not called because you are using newton with simd on.
if you set a break point on teh funtion just above that
dgFloat32 FastRayTest::PolygonIntersectSimd (const dgVector& normal, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) const
you will see that, tha is teh one the is called.
you can do few thongs
-make the changes to the simd version PolygonIntersectSimd (hardest)
-set newton to work in x86 mode, (simpler)
-just have PolygonIntersectSimd calling PolygonIntersect, (I guess tha will be the easier) that way the other optimization will still be on.
writing collision engine is, not as trivial as you think it is,
collision routine are part of computational geometry, and althought the algrithms are thereticall simple they are numerical unstable, to get them acurate, rubust and Fast is not a trivial task.
Newton has many, many algorithm of my own, that are very robust fast and acurate.
that simple ray cast function is very different that any Raycast you will find on any book of any internet publication.
basically the interseption routine is extremally robust since is does all the calculation on volumetric space and oposse to other techinques that projection the point over the plane of the triangle and do point in polygon test.
My suggestion is that for you is faster to modify those funtions first, until you feel confident. if you decide to start your own gemetrical engine from scratch, I can asure you, a year from now you will still be
debuging round off errors, performace issue, and plain simple crashes. Thust me on that. some competitors had a going for years, still going, and still they do now get is right.
In fact there are some comercial engiene that still get it wrong.
incidentally in 1999 I used that same collision routine and collision tree for a offline light map caster for company I worked for. and it did work very well.
we did not had refraction them.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by AdrianCG » Mon Sep 12, 2011 2:53 pm
Hi again,
Actually i have printed a message everytime the FastRayTest::PolygonIntersect method is called. It is called if the ray is outside the triangulated sphere and not called if the origin is inside. At first i thought there is a test somewhere higher in the method call hierarchy that rejects the ray but i'm not really sure about this.
Regarding the writing of a collision engine, i surely don't expect to write a state-of-the art collision engine. Practically i'll be needing ray sphere intersection, ray AABB intersection, ray triangle intersection and an easy to build (with decent efficiency) BVH. Having previous experience with similar issues (i have coded,in the past, a full BSP /Automatic portal generation/ BSP 3D engine and used it for continuous collision detection-and response with sliding- with ellipsoids). Surely this can't be that hard, and i'm not aiming for high precision, high robustness. I'll also be needing to port the code to OpenCL and make the raytracer as fast as i can

. Also, i'm not completely throwing newton away, i'll be using it for making short physics driven movies that'll show the OpenCL accelerated raytracer rendering capabilities. That said, even if i do use newton now, somewhere in the future i'll have to write my own collision detection routines to port them to OpenCL.
-
AdrianCG
-
- Posts: 10
- Joined: Thu Sep 08, 2011 6:55 am
by Julio Jerez » Mon Sep 12, 2011 3:27 pm
AdrianCG wrote:Hi again,
Actually i have printed a message everytime the FastRayTest::PolygonIntersect method is called. It is called if the ray is outside the triangulated sphere and not called if the origin is inside. At first i thought there is a test somewhere higher in the method call hierarchy that rejects the ray but i'm not really sure about this.
That can not be possible, a collision tree is a poygon soup, and it will have no way of knowing what si inside of out side of a solid objet.
if you added a speher as a collision of faces, the Ray cast routine will be called fir each face tha inteset the ray, regarless of teh ray hiting form inside of outside.
like I say teh code must be calling the simd version.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest