Game Development Community

ShapeBase::buildConvex question

by Michael Anderson · in Torque Game Engine · 09/18/2006 (4:24 pm) · 8 replies

At the top of this method resides the following code:

Box3F realBox = box;
mWorldToObj.mul(realBox);
realBox.min.convolveInverse(mObjScale);
realBox.max.convolveInverse(mObjScale);

if (realBox.isOverlapped(getObjBox()) == false)
return;

I am not quite sure what this does, my understanding is that the box passed into this method is the scene bin box that is already in world space so what is this realbox?

#1
09/18/2006 (7:19 pm)
RealBox is the query box submitted to the shape for collision info to be returned for (if any).

So the first thing the object does is check if the query box actually overlaps the object's box. If not there's no way any further calculation could help, so it skips out.
#2
09/19/2006 (10:07 am)
But why transform the incoming box, isn't it in worldspace already? Couldn't you just compare the transformed bounding box against box (instead of computing realBox)?
#3
09/19/2006 (10:09 am)
Because if you check in object space you'll get more rejections - compare the relative volume of the two boxes in the world editor, which represent the object and world box for each shape.
#4
09/19/2006 (10:45 am)
Ahh okay makes sense, one last question: I have never seen the word convolve in any linear algebra text, first time I saw it I was like: "oh my, it's convolving", is there some reason scale, or mult wasn't used? :)
#5
09/19/2006 (11:18 am)
It's a signal processing term (vis convolution matrix), and it's that way mostly cuz that's how it was written. :P

I think the term was chosen to make it clear exactly what the method did as compared to dot, cross product, etc.

That particular math code probably dates back ten years. :)
#6
09/19/2006 (11:54 am)
I always wondered what to call that component-wise multiplication
and was so stoked to find "convolve" in the TGE code.
so now i go around saying "convolve" all the time, and making my friends hate me.

vector scale   (v1, k ) = [v1.x * k   ,  v1.y * k   ,  v1.z * k   ]
vector convolve(v1, v2) = [v1.x * v2.x,  v1.y * v2.y,  v1.z * v2.z]
#7
09/20/2006 (12:30 pm)
I have another question about ShapeBase::buildConvex: It looks like the collision detail bounding box that is used in the overlap test is not transformed by it's node matrix (nor is animate called), so for animated collision details the overlap test could be wrong.
#8
09/20/2006 (6:01 pm)
Is there a reason why ShapeBase::Convex uses the shape accelerator for support and getFeatures, but not getPolyList? Why not use the support and getFeatures methods of the shape instance rather then the shape accelerator? It also appears the ShapeBase::Convex getTransform, and getBoundingBox methods don't take into consideration the node transform associated with the collision detail either. Seems to me that this code works for most cases but is broken for the edge cases. Please correct me if I am wrong.