iMiniB3D entity with child scale problem

BlitzMax Forums/MiniB3D Module/iMiniB3D entity with child scale problem

ima747(Posted 2012) [#1]
I suspect this is known by Simon, but just never got around to getting it fixed...

If you scale an entity then make it the parent of a second entity, the scale is applied to the child entity. This is done when the entity is parented and not undone when the child is unlinked. The result is if you parent multiple times the child will squish or stretch more and more each time.

There is a mark at like 132 in entity.mm to fix a recursion crash with a commented out call to ScaleEntity, which I suspect is needed to fix this...

haven't dug into the recursion but it looks pretty nasty... currently just trying to hack out any scaling based on a parent but it's not working right so might be best to just find a real fix... any insight would be appreciated.


ima747(Posted 2012) [#2]
my current hack is to scale meshes instead of entities. It's not a fix, and requires a lot more state checking on my part (have to track the mesh's scaling so I can reset it when I need to change it later etc.) but it will work in the mean time for me... would still like to get this sorted if anyone has any throughs.


AdamRedwoods(Posted 2012) [#3]
can you get by changing the line to:

ScaleEntity(gsx,gsy,gsz,false);

it should still take into account the parent entity's scale. Not sure how it will effect children of children.
I"ll have to see if this effects monkey minib3d as well.


ima747(Posted 2012) [#4]
Tried that doesn't crash but doesn't fix the scaling issue.


AdamRedwoods(Posted 2012) [#5]
ah, right. Well I think one way is to normalize the 4x4 rotation matrix and add back in your local scaling and position. (under geom.h: MMatrix::orthogonalized)

how does it crash? i don't see where it would. infinite loop? null value? divide by 0?


ima747(Posted 2012) [#6]
Infinite recursion until boom. Has to do with updating children so it's spread across multiple functions. For now mesh scaling is working for me and I don't have time to tear everything down myself, but have a slew of comments in my own code to explain why I'm bypassing entity scaling so hopefully I'll get back to it...