bodguy / Theodore

Unity inspired game engine for easy to use written in C++.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AABB rendering problem

bodguy opened this issue · comments

When rendering AABB in the scene, there are weird visual problem. AABB does not contain OBB roughly and its shape seems not be correctly rendered. I guess this problem origins from multiplying abs model matrix and its extents. these codes are performed in MeshRenderer Update function. but I don't have any idea to handle it. maybe it will take several weeks to fix it.

I finally fix it. The model matrix is not a local to world matrix anymore but world to local matrix. It seems to be work well but the inverse of world matrix(aka, model) will cause inverse translation and scaling problems. I use both matrix to utilize each of components.

World matrix (aka, localToWorldMatrix) has correct translation and scaling parts. Otherwise Model matrix (aka, WorldToLocalMatrix) has combined rotation matrix with scaling. Now I use "Model" to extract rotation of AABB extents(halfLength) and use "World" to extract translation and scaling.

But there was several problems. "Model" had inverse of scale of world matrix. So just multiplying World scale and Model scale caused a no effect for any scaling changes(AA-1=E). this bug was fixed with my brilliant trick. I use world scaling parts to power of two fashion. it has some waste of cpu processing time but shows quite well performance.