fix: some fix for visuals in 3D

This commit is contained in:
Kazhnuz 2024-11-02 08:37:38 +01:00
parent 816c6fee22
commit bde4808d7b

View file

@ -31,7 +31,7 @@ function Visual:_updateVisual(dt)
end
end
function Visual:_getShapeData(mode)
function Visual:_getShapeData()
local position = self.position:clone()
local dimensions = {
w = self.dimensions.w,
@ -39,30 +39,33 @@ function Visual:_getShapeData(mode)
d = self.dimensions.d
}
if (mode == "3D") then
if (self.world.type == "3D") then
-- TODO: vérifier si l'algo est bon
position.y = position.y - self.dimensions.d - position.z
position.y = position.y - self.dimensions.d - position.z + (self.dimensions.h)
dimensions = {
w = self.dimensions.w,
h = self.dimensions.h,
h = self.dimensions.h + self.dimensions.d,
d = self.dimensions.d
}
end
print(self.world.type, position)
return position, dimensions
end
function Visual:_getViewCenter(mode)
local position = self.position + (physicsUtils.dimensionsToVector(self.dimensions) / 2)
if (mode == "3D") then
position.y = position.y - self.dimensions.d
if (self.world.type == "3D") then
position.y = position.y - (self.dimensions.d / 2)
end
return position
end
function Visual:_drawVisual()
self.visual:draw(self.position, self.dimensions);
local position, dimensions = self:_getShapeData()
self.visual:draw(position, dimensions);
end
-- RECT HANDLING