Fixed capsule auxgeom draw for lights and other aux geom issues
Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com>
This commit is contained in:
@@ -314,15 +314,35 @@ namespace AZ
|
||||
AddShape(style, shape);
|
||||
}
|
||||
|
||||
void AuxGeomDrawQueue::DrawSphere(
|
||||
const AZ::Vector3& center,
|
||||
Matrix3x3 CreateMatrix3x3FromDirection(const AZ::Vector3& direction)
|
||||
{
|
||||
Vector3 unitDirection(direction.GetNormalized());
|
||||
Vector3 unitOrthogonal(direction.GetOrthogonalVector().GetNormalized());
|
||||
Vector3 unitCross(unitOrthogonal.Cross(unitDirection));
|
||||
return Matrix3x3::CreateFromColumns(unitOrthogonal, unitDirection, unitCross);
|
||||
}
|
||||
|
||||
void AuxGeomDrawQueue::DrawSphere(const AZ::Vector3& center, float radius, const AZ::Color& color, DrawStyle style, DepthTest depthTest, DepthWrite depthWrite, FaceCullMode faceCull, int32_t viewProjOverrideIndex)
|
||||
{
|
||||
DrawSphereCommon(center, AZ::Vector3::CreateAxisY(), radius, color, style, depthTest, depthWrite, faceCull, viewProjOverrideIndex, false);
|
||||
}
|
||||
|
||||
void AuxGeomDrawQueue::DrawHemisphere(const AZ::Vector3& center, const AZ::Vector3& direction, float radius, const AZ::Color& color, DrawStyle style, DepthTest depthTest, DepthWrite depthWrite, FaceCullMode faceCull, int32_t viewProjOverrideIndex)
|
||||
{
|
||||
DrawSphereCommon(center, direction, radius, color, style, depthTest, depthWrite, faceCull, viewProjOverrideIndex, true);
|
||||
}
|
||||
|
||||
void AuxGeomDrawQueue::DrawSphereCommon(
|
||||
const AZ::Vector3& center,
|
||||
const AZ::Vector3& direction,
|
||||
float radius,
|
||||
const AZ::Color& color,
|
||||
DrawStyle style,
|
||||
DepthTest depthTest,
|
||||
DepthWrite depthWrite,
|
||||
FaceCullMode faceCull,
|
||||
int32_t viewProjOverrideIndex)
|
||||
int32_t viewProjOverrideIndex,
|
||||
bool isHemisphere)
|
||||
{
|
||||
if (radius <= 0.0f)
|
||||
{
|
||||
@@ -330,12 +350,12 @@ namespace AZ
|
||||
}
|
||||
|
||||
ShapeBufferEntry shape;
|
||||
shape.m_shapeType = ShapeType_Sphere;
|
||||
shape.m_shapeType = isHemisphere ? ShapeType_Hemisphere : ShapeType_Sphere;
|
||||
shape.m_depthRead = ConvertRPIDepthTestFlag(depthTest);
|
||||
shape.m_depthWrite = ConvertRPIDepthWriteFlag(depthWrite);
|
||||
shape.m_faceCullMode = ConvertRPIFaceCullFlag(faceCull);
|
||||
shape.m_color = color;
|
||||
shape.m_rotationMatrix = Matrix3x3::CreateIdentity();
|
||||
shape.m_rotationMatrix = CreateMatrix3x3FromDirection(direction);
|
||||
shape.m_position = center;
|
||||
shape.m_scale = AZ::Vector3(radius, radius, radius);
|
||||
shape.m_pointSize = m_pointSize;
|
||||
@@ -362,13 +382,9 @@ namespace AZ
|
||||
shape.m_faceCullMode = ConvertRPIFaceCullFlag(faceCull);
|
||||
shape.m_color = color;
|
||||
|
||||
Vector3 unitDirection(direction.GetNormalized());
|
||||
Vector3 unitOrthogonal(direction.GetOrthogonalVector().GetNormalized());
|
||||
Vector3 unitCross(unitOrthogonal.Cross(unitDirection));
|
||||
|
||||
// The disk mesh is created with the top of the disk pointing along the positive Y axis. This creates a
|
||||
// rotation so that the top of the disk will point along the given direction vector.
|
||||
shape.m_rotationMatrix = Matrix3x3::CreateFromColumns(unitOrthogonal, unitDirection, unitCross);
|
||||
shape.m_rotationMatrix = CreateMatrix3x3FromDirection(direction);
|
||||
shape.m_position = center;
|
||||
shape.m_scale = AZ::Vector3(radius, 1.0f, radius);
|
||||
shape.m_pointSize = m_pointSize;
|
||||
@@ -401,13 +417,7 @@ namespace AZ
|
||||
shape.m_faceCullMode = ConvertRPIFaceCullFlag(faceCull);
|
||||
shape.m_color = color;
|
||||
|
||||
Vector3 unitDirection(direction.GetNormalized());
|
||||
Vector3 unitOrthogonal(direction.GetOrthogonalVector().GetNormalized());
|
||||
Vector3 unitCross(unitOrthogonal.Cross(unitDirection));
|
||||
|
||||
// The cone mesh is created with the tip of the cone pointing along the positive Y axis. This creates a
|
||||
// rotation so that the tip of the cone will point along the given direction vector.
|
||||
shape.m_rotationMatrix = Matrix3x3::CreateFromColumns(unitOrthogonal, unitDirection, unitCross);
|
||||
shape.m_rotationMatrix = CreateMatrix3x3FromDirection(direction);
|
||||
shape.m_position = center;
|
||||
shape.m_scale = AZ::Vector3(radius, height, radius);
|
||||
shape.m_pointSize = m_pointSize;
|
||||
@@ -416,17 +426,30 @@ namespace AZ
|
||||
AddShape(style, shape);
|
||||
}
|
||||
|
||||
void AuxGeomDrawQueue::DrawCylinder(
|
||||
const AZ::Vector3& center,
|
||||
const AZ::Vector3& direction,
|
||||
float radius,
|
||||
float height,
|
||||
const AZ::Color& color,
|
||||
DrawStyle style,
|
||||
DepthTest depthTest,
|
||||
DepthWrite depthWrite,
|
||||
FaceCullMode faceCull,
|
||||
int32_t viewProjOverrideIndex)
|
||||
void AuxGeomDrawQueue::DrawCylinder(const AZ::Vector3& center, const AZ::Vector3& direction, float radius, float height, const AZ::Color& color,
|
||||
DrawStyle style, DepthTest depthTest, DepthWrite depthWrite, FaceCullMode faceCull, int32_t viewProjOverrideIndex)
|
||||
{
|
||||
DrawCylinderCommon(center, direction, radius, height, color, style, depthTest, depthWrite, faceCull, viewProjOverrideIndex, true);
|
||||
}
|
||||
|
||||
void AuxGeomDrawQueue::DrawCylinderNoEnds(const AZ::Vector3& center, const AZ::Vector3& direction, float radius, float height, const AZ::Color& color,
|
||||
DrawStyle style, DepthTest depthTest, DepthWrite depthWrite, FaceCullMode faceCull, int32_t viewProjOverrideIndex)
|
||||
{
|
||||
DrawCylinderCommon(center, direction, radius, height, color, style, depthTest, depthWrite, faceCull, viewProjOverrideIndex, false);
|
||||
}
|
||||
|
||||
void AuxGeomDrawQueue::DrawCylinderCommon(
|
||||
const AZ::Vector3& center,
|
||||
const AZ::Vector3& direction,
|
||||
float radius,
|
||||
float height,
|
||||
const AZ::Color& color,
|
||||
DrawStyle style,
|
||||
DepthTest depthTest,
|
||||
DepthWrite depthWrite,
|
||||
FaceCullMode faceCull,
|
||||
int32_t viewProjOverrideIndex,
|
||||
bool drawEnds)
|
||||
{
|
||||
if (radius <= 0.0f || height <= 0.0f)
|
||||
{
|
||||
@@ -434,19 +457,15 @@ namespace AZ
|
||||
}
|
||||
|
||||
ShapeBufferEntry shape;
|
||||
shape.m_shapeType = ShapeType_Cylinder;
|
||||
shape.m_depthRead = ConvertRPIDepthTestFlag(depthTest);
|
||||
shape.m_shapeType = drawEnds ? ShapeType_Cylinder : ShapeType_CylinderNoEnds;
|
||||
shape.m_depthRead = ConvertRPIDepthTestFlag(depthTest);
|
||||
shape.m_depthWrite = ConvertRPIDepthWriteFlag(depthWrite);
|
||||
shape.m_faceCullMode = ConvertRPIFaceCullFlag(faceCull);
|
||||
shape.m_color = color;
|
||||
|
||||
Vector3 unitDirection(direction.GetNormalized());
|
||||
Vector3 unitOrthogonal(direction.GetOrthogonalVector().GetNormalized());
|
||||
Vector3 unitCross(unitOrthogonal.Cross(unitDirection));
|
||||
|
||||
// The cylinder mesh is created with the top end cap of the cylinder facing along the positive Y axis. This creates a
|
||||
// rotation so that the top face of the cylinder will face along the given direction vector.
|
||||
shape.m_rotationMatrix = Matrix3x3::CreateFromColumns(unitOrthogonal, unitDirection, unitCross);
|
||||
shape.m_rotationMatrix = CreateMatrix3x3FromDirection(direction);
|
||||
shape.m_position = center;
|
||||
shape.m_scale = AZ::Vector3(radius, height, radius);
|
||||
shape.m_pointSize = m_pointSize;
|
||||
|
||||
Reference in New Issue
Block a user