Quote:
Originally Posted by Immortal_BLG
Hello!
Is it possible to correctly shift planes?
If so - how to do this?
I need to shift the clip-planes so that their distances was the same distances of the point-hull planes.
I do so:
...
but this won't work for some planes (for example floor) - this conversely shifts plane to opposite side.
Please help.
|
To be sure I understand what you are looking for:
1. the point-hull bsp provided in the bsp file, as opposed to the 3 others bsps ( human, head,..) is used in HL for drawing, not for movement( ie collision detection); so some clipping ( blocking) faces are not taken into account when building the point-hull bsp tree because they are not drawn.
I assume you want a COLLISION bsp tree for the point and not a DRAWING bsp tree; so you use one of the other bsp trees as a starting point ( because it takes clipping faces into account), and "moving back" its (clipping) planes so that the "thickness" resulting from the hull is reduced to zero, reducing implicitely the hull to a point.
Is that right?
If it is right, I do not see how you can guarantee that you will get all the original planes.
As regard your code, I cannot see how the code itself can be right in some cases and wrong in some others.
I mentionned FACES instead of planes because in general the normal of a clipping plane alone cannot tell if the SOLID ( or move-blocking if you wish) side is in front of the plane or in its back. On the contrary, the "contents" data of a face always describes what is in its back ( but the face normal maybe equal or opposite to its supporting plane one).
My conclusion is that your code is right ( providing plane.distance has the right signing!), but you make an assumption on the meaning of the plane normal relative the SOLID side which is sometimes right,sometimes wrong.
EDIT I forgot: your code is ok in principle but there is a tweak in the way the bsps are build: the planes are actually shifted horizontally by a CONSTANT value, as if the hulls were vertical CYLINDERS.