Forum: Poser Python Scripting


Subject: Moving morphs between different figures

Cage opened this issue on Dec 20, 2006 · 1232 posts


Spanki posted Sun, 23 March 2008 at 1:06 AM

This may be a bunch of partial posts/answers....

re: negative distances...

Ok, the short answer is that you're right - distance values are typically inherently always positive - getting the length of a vector always returns a positive value.  The longer answer is that this particular distance value is not generated by geting the length of a vector, it's used to create the vector in the first place :).  In the original code, we computed the intersection distance as follows...

intersect = (pplanes[pdx] - ndotv)/ndota

...which can be negative, as it is also used to determine a direction, and used to build the actual intersection point...

                point = [v[0] + (ray[0] * intersect),
                         v[1] + (ray[1] * intersect),
                         v[2] + (ray[2] * intersect)]    #ray_segment(v, ray, intersect)

...(which would now be performed with this extension like so:  point = v.project(ray, intersect) ).  We later do abs() comparisons with the matchdist variable, and used that to keep track of the closest match.   Once done looping, we used matchdist to re-create the intersection point (so it still needed to have a sign/direction), but in the old code, we never really stored/returned it as a distance - we just stored the actual intersection point.

So, the new C++ code is based on a similar functionality, except that it now stores/returns the value as the hp.HitDist member.  Of course we also have the actual intersection, so we don't need to keep the sign of the distance anymore, but it is being used internally to "prime the internal matchdist variable" if there's a pre-existing value there (if that vertex gets passed through the comparison routine again).

My current thought would be to leave it as is for now and just document the fact that it can be negative.  I guess it may be a point of semantics... it might better be described as a 'scalar', but what it represents is both the distance and the direction (either positive or negative, along the vertex normal) from the current position to the intersection point.

Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.