[SOLVED] Lemur Collision Detection

I realized that my ComboBox was actually a drop down menu :), so I renamed it to DropDown and then created an actual ComboBox. During the process I noticed that when a button is resized the collision detection bounds are only resized if the button shrinks, but not if it grows. Here’s a couple of screen caps to illustrate:

When I start out with the first image then select the larger text the button grows, but the new larger button only responds to hover events or button click events if they occur in the green highlighted area which is the original size of the button. Any thoughts on this, do you think this would be Lemur or jME related?

I’ve tried adding Geometry.updateModelBound() whenever the GradientBackgroundComponent mesh is resized and also tried detaching the Geometry, creating a new one with the resized Mesh then attaching the new Geometry with the same results.

Never mind I got it. I took a peek at jME’s Mesh class and found in the collideWith method:

if (collisionTree == null){

I think the problem here is that collisionTree is not reset to null when the VertexBuffers are updated so in my BrdrPlane Mesh’s updateGeometry method I inserted createCollisionData() at the end.

Yeah, but I wonder why I haven’t hit this with my own components. I may have to do a little testing to confirm but I don’t believe I’ve seen it.

I’ve traced through the Quad and Mesh code and I can’t see how I avoid it, though. Could be I neew a similar fix to call clearCollisionData() when I change size. You probably want to call clear instead of create to avoid creating the collision data multiple times before it’s needed. (Say the component is resized a couple times before clicked again.)

I guess I can’t say for sure. Looking at your TbtQuad Mesh the only thing I’m doing different in terms of modifying the buffers and such is that you’re calling setBuffer(Type type, int components, float[] buf) with new float/short arrays whenever the mesh is updated.

I use that same method on the initial creation of the mesh, but when the mesh is updated I getBuffer(Type type) to get the VertexBuffer already set on the Mesh then get the underlying Float/ShortBuffer from that and modify it’s contents in order to reuse the existing buffers, when I’m done I call VertexBuffer.updateData(Buffer data) and then setBuffer(VertexBuffer vb).

Looking through Mesh.java and VertexBuffer.java there isn’t really anything different between the two methods, the only difference is that in one the old buffer becomes garbage in the other the old buffer is reused with new data.

There doesn’t appear to be any calls to createCollisionData() or clearCollisionData() at any point along the path when updating buffers. I’m also calling updateBound() when I’m done, but that method does not clear the collision data.

Yeah, I saw the same when I looked.

I’ll have to make a test and see if I also have the error.

I just tested it, the TbtQuad also has the problem. Maybe adding clearCollisionData() to Mesh.updateBound()?

Seems like it should work, I think all the default Mesh objects that allow dynamic re-creation call updateBound(), but I don’t think any of them call clearCollisionData().

Could also add something like:

if (vb.getBufferType() == Type.Position) {

To the setBuffer(VertexBuffer vb) method.

No, updateBound() would be better… we had this discussion what I feel like was years ago and I don’t remember why it’s not already like this.

1 Like