-
Macro translation
I am trying to analyze some code and I ran into this giant macro. Can someone please translate this into an equivalent C function?
Code:
#define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
(((p)->type < 3)? \
( \
((p)->dist <= (emins)[(p)->type])? \
1 \
: \
( \
((p)->dist >= (emaxs)[(p)->type])? \
2 \
: \
3 \
) \
) \
: \
BoxOnPlaneSide( (emins), (emaxs), (p)))
-
Notice that when p->type is greater than or equal to 3 it calls something else called BoxOnPlaneSide(). Otherwise it resolves to one of the precalculated answers, 1, 2, or 3. That's pretty much all it does. The ternary operator ?: is really just another way to write an if else as a statement, and I think it is being abused here.
-
Great, thats all I needed to know. Thanks for the help