fix: some fix for visuals in 3D
This commit is contained in:
parent
816c6fee22
commit
bde4808d7b
1 changed files with 10 additions and 7 deletions
|
@ -31,7 +31,7 @@ function Visual:_updateVisual(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Visual:_getShapeData(mode)
|
function Visual:_getShapeData()
|
||||||
local position = self.position:clone()
|
local position = self.position:clone()
|
||||||
local dimensions = {
|
local dimensions = {
|
||||||
w = self.dimensions.w,
|
w = self.dimensions.w,
|
||||||
|
@ -39,30 +39,33 @@ function Visual:_getShapeData(mode)
|
||||||
d = self.dimensions.d
|
d = self.dimensions.d
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == "3D") then
|
if (self.world.type == "3D") then
|
||||||
-- TODO: vérifier si l'algo est bon
|
-- 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 = {
|
dimensions = {
|
||||||
w = self.dimensions.w,
|
w = self.dimensions.w,
|
||||||
h = self.dimensions.h,
|
h = self.dimensions.h + self.dimensions.d,
|
||||||
d = self.dimensions.d
|
d = self.dimensions.d
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
print(self.world.type, position)
|
||||||
|
|
||||||
return position, dimensions
|
return position, dimensions
|
||||||
end
|
end
|
||||||
|
|
||||||
function Visual:_getViewCenter(mode)
|
function Visual:_getViewCenter(mode)
|
||||||
local position = self.position + (physicsUtils.dimensionsToVector(self.dimensions) / 2)
|
local position = self.position + (physicsUtils.dimensionsToVector(self.dimensions) / 2)
|
||||||
if (mode == "3D") then
|
if (self.world.type == "3D") then
|
||||||
position.y = position.y - self.dimensions.d
|
position.y = position.y - (self.dimensions.d / 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
return position
|
return position
|
||||||
end
|
end
|
||||||
|
|
||||||
function Visual:_drawVisual()
|
function Visual:_drawVisual()
|
||||||
self.visual:draw(self.position, self.dimensions);
|
local position, dimensions = self:_getShapeData()
|
||||||
|
self.visual:draw(position, dimensions);
|
||||||
end
|
end
|
||||||
|
|
||||||
-- RECT HANDLING
|
-- RECT HANDLING
|
||||||
|
|
Loading…
Add table
Reference in a new issue