|
|
> What if instead of re-transforming the mesh data, you transform the reference
> point to measure the length?
> Then it's only ever one transform in either direction.
>
That is exactly what I tried, if I am understanding you.
I want to find the distance from point P to mesh M (which contains
vertex/triangle data as well as a transformation).
So I tried basically this:
P_inv = InverseTransformPoint(P, M->Trans)
N = NearestPoint(P_inv, M->Data)
V = N - P_inv // get the vector from P_inv to N
V_trans = TransformDirection(V, M->Trans)
If(Inside(P, M))
distance = -Length(V_trans)
Else
distance = Length(V_trans)
....and the result was much worse than finding the distance from point P to mesh
M (which contains transformed vertex/triangle data), but doing this:
N = NearestPoint(P, TransformAllVertices(M->Data, M->Trans))
V = N - P
If(Inside(P, M))
distance = -Length(V)
Else
distance = Length(V)
I mean, obviously the second one looks cleaner, as well, but it hides all the
code required to make sure M->TransformedData is there to use.
Post a reply to this message
|
|