mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 14:24:56 +00:00
SIMD refactor
This commit is contained in:
@@ -93,15 +93,15 @@ void Buckets::Sort()
|
||||
bool partial, full;
|
||||
if (planeObj.x3c_25_zOnly)
|
||||
{
|
||||
partial = drawable.GetBounds().max.z > planeObj.GetPlane().d;
|
||||
full = drawable.GetBounds().min.z > planeObj.GetPlane().d;
|
||||
partial = drawable.GetBounds().max.z() > planeObj.GetPlane().d();
|
||||
full = drawable.GetBounds().min.z() > planeObj.GetPlane().d();
|
||||
}
|
||||
else
|
||||
{
|
||||
partial = planeObj.GetPlane().pointToPlaneDist(
|
||||
drawable.GetBounds().closestPointAlongVector(planeObj.GetPlane().vec)) > 0.f;
|
||||
drawable.GetBounds().closestPointAlongVector(planeObj.GetPlane().normal())) > 0.f;
|
||||
full = planeObj.GetPlane().pointToPlaneDist(
|
||||
drawable.GetBounds().furthestPointAlongVector(planeObj.GetPlane().vec)) > 0.f;
|
||||
drawable.GetBounds().furthestPointAlongVector(planeObj.GetPlane().normal())) > 0.f;
|
||||
}
|
||||
bool cont;
|
||||
if (drawable.GetType() == EDrawableType::Particle)
|
||||
@@ -378,7 +378,7 @@ void CBooRenderer::CalcDrawFogFan(const zeus::CPlane* planes, int numPlanes, con
|
||||
u32 insidePlaneCount = 0;
|
||||
bool outsidePlane[20];
|
||||
for (int i=0 ; i<numVerts ; ++i)
|
||||
outsidePlane[insidePlaneCount++] = plane.normal().dot(verts[i]) < plane.d;
|
||||
outsidePlane[insidePlaneCount++] = plane.normal().dot(verts[i]) < plane.d();
|
||||
|
||||
u32 numUseVerts = 0;
|
||||
zeus::CVector3f useVerts[20];
|
||||
@@ -435,7 +435,7 @@ void CBooRenderer::DrawFogSlices(const zeus::CPlane* planes, int numPlanes,
|
||||
|
||||
zeus::CVector3d planeNormal = plane.normal();
|
||||
for (const zeus::CVector3d& vert : verts)
|
||||
verts2[vert2Count++] = vert - (planeNormal * zeus::CVector3f(planeNormal.dot(vert) - plane.d));
|
||||
verts2[vert2Count++] = vert - (planeNormal * zeus::CVector3f(planeNormal.dot(vert) - plane.d()));
|
||||
|
||||
CalcDrawFogFan(planes, numPlanes, verts2, vert2Count, iteration, 0, fogVol);
|
||||
}
|
||||
@@ -452,21 +452,21 @@ void CBooRenderer::RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel*
|
||||
zeus::CUnitVector3f viewNormal(viewMtx.basis[1]);
|
||||
zeus::CPlane planes[7] =
|
||||
{
|
||||
{zeus::CVector3f::skRight, xfAABB.min.x},
|
||||
{zeus::CVector3f::skLeft, -xfAABB.max.x},
|
||||
{zeus::CVector3f::skForward, xfAABB.min.y},
|
||||
{zeus::CVector3f::skBack, -xfAABB.max.y},
|
||||
{zeus::CVector3f::skUp, xfAABB.min.z},
|
||||
{zeus::CVector3f::skDown, -xfAABB.max.z},
|
||||
{zeus::CVector3f::skRight, xfAABB.min.x()},
|
||||
{zeus::CVector3f::skLeft, -xfAABB.max.x()},
|
||||
{zeus::CVector3f::skForward, xfAABB.min.y()},
|
||||
{zeus::CVector3f::skBack, -xfAABB.max.y()},
|
||||
{zeus::CVector3f::skUp, xfAABB.min.z()},
|
||||
{zeus::CVector3f::skDown, -xfAABB.max.z()},
|
||||
{viewNormal, viewNormal.dot(viewMtx.origin) + 0.2f + 0.1f}
|
||||
};
|
||||
|
||||
CGraphics::SetModelMatrix(zeus::CTransform::Identity());
|
||||
|
||||
float longestAxis = std::max(std::max(
|
||||
xfAABB.max.x - xfAABB.min.x,
|
||||
xfAABB.max.y - xfAABB.min.y),
|
||||
xfAABB.max.z - xfAABB.min.z) * 2.f;
|
||||
xfAABB.max.x() - xfAABB.min.x(),
|
||||
xfAABB.max.y() - xfAABB.min.y()),
|
||||
xfAABB.max.z() - xfAABB.min.z()) * 2.f;
|
||||
|
||||
fvs->reset(7 * 6);
|
||||
for (int i=0 ; i<7 ; ++i)
|
||||
@@ -541,23 +541,23 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
|
||||
zeus::CVector3f overW;
|
||||
if (i < 8)
|
||||
{
|
||||
overW = points[i].toVec3f() * (1.f / points[i].w);
|
||||
overW = points[i].toVec3f() * (1.f / points[i].w());
|
||||
}
|
||||
else
|
||||
{
|
||||
const zeus::CVector4f& pt1 = points[s_FogVolumeCtrl.xfc_[i-8][0]];
|
||||
const zeus::CVector4f& pt2 = points[s_FogVolumeCtrl.xfc_[i-8][1]];
|
||||
|
||||
bool eq1 = (pt1.z / pt1.w) == 1.f;
|
||||
bool eq2 = (pt2.z / pt2.w) == 1.f;
|
||||
bool eq1 = (pt1.z() / pt1.w()) == 1.f;
|
||||
bool eq2 = (pt2.z() / pt2.w()) == 1.f;
|
||||
if (eq1 == eq2)
|
||||
continue;
|
||||
|
||||
float interp = -(pt1.w - 1.f) / (pt2.w - pt1.w);
|
||||
float interp = -(pt1.w() - 1.f) / (pt2.w() - pt1.w());
|
||||
if (interp <= 0.f || interp >= 1.f)
|
||||
continue;
|
||||
|
||||
float wRecip = 1.f / (interp * (pt2.w - pt1.w) + pt1.w);
|
||||
float wRecip = 1.f / (interp * (pt2.w() - pt1.w()) + pt1.w());
|
||||
zeus::CVector3f pt1_3 = pt1.toVec3f();
|
||||
zeus::CVector3f pt2_3 = pt2.toVec3f();
|
||||
overW = (pt1_3 + interp * (pt2_3 - pt1_3)) * wRecip;
|
||||
@@ -566,8 +566,8 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
|
||||
//if (overW.z > 1.001f)
|
||||
// continue;
|
||||
|
||||
int vpX = zeus::clamp(0, int(g_Viewport.x8_width * overW.x * 0.5f + (g_Viewport.x8_width / 2)), int(g_Viewport.x8_width));
|
||||
int vpY = zeus::clamp(0, int(g_Viewport.xc_height * overW.y * 0.5f + (g_Viewport.xc_height / 2)), int(g_Viewport.xc_height));
|
||||
int vpX = zeus::clamp(0, int(g_Viewport.x8_width * overW.x() * 0.5f + (g_Viewport.x8_width / 2)), int(g_Viewport.x8_width));
|
||||
int vpY = zeus::clamp(0, int(g_Viewport.xc_height * overW.y() * 0.5f + (g_Viewport.xc_height / 2)), int(g_Viewport.xc_height));
|
||||
vpMax.x = std::max(vpMax.x, vpX);
|
||||
vpMin.x = std::min(vpMin.x, vpX);
|
||||
vpMax.y = std::max(vpMax.y, vpY);
|
||||
@@ -758,7 +758,7 @@ void CBooRenderer::AddWorldSurfaces(CBooModel& model)
|
||||
{
|
||||
const MaterialSet::Material& mat = model.GetMaterialByIndex(surf->m_data.matIdx);
|
||||
zeus::CAABox aabb = surf->GetBounds();
|
||||
zeus::CVector3f pt = aabb.closestPointAlongVector(xb0_viewPlane.vec);
|
||||
zeus::CVector3f pt = aabb.closestPointAlongVector(xb0_viewPlane.normal());
|
||||
Buckets::Insert(pt, aabb, EDrawableType::WorldSurface, surf, xb0_viewPlane,
|
||||
mat.heclIr.m_blendSrc == boo::BlendFactor::SrcAlpha &&
|
||||
mat.heclIr.m_blendDst == boo::BlendFactor::InvSrcAlpha);
|
||||
@@ -1026,16 +1026,20 @@ void CBooRenderer::PostRenderFogs()
|
||||
x2ac_fogVolumes.sort([](const CFogVolumeListItem& a, const CFogVolumeListItem& b)
|
||||
{
|
||||
zeus::CAABox aabbA = a.x34_aabb.getTransformedAABox(a.x0_transform);
|
||||
bool insideA = aabbA.pointInside(zeus::CVector3f(CGraphics::g_ViewPoint.x, CGraphics::g_ViewPoint.y, aabbA.min.z));
|
||||
bool insideA = aabbA.pointInside(
|
||||
zeus::CVector3f(CGraphics::g_ViewPoint.x(), CGraphics::g_ViewPoint.y(), aabbA.min.z()));
|
||||
|
||||
zeus::CAABox aabbB = b.x34_aabb.getTransformedAABox(b.x0_transform);
|
||||
bool insideB = aabbB.pointInside(zeus::CVector3f(CGraphics::g_ViewPoint.x, CGraphics::g_ViewPoint.y, aabbB.min.z));
|
||||
bool insideB = aabbB.pointInside(
|
||||
zeus::CVector3f(CGraphics::g_ViewPoint.x(), CGraphics::g_ViewPoint.y(), aabbB.min.z()));
|
||||
|
||||
if (insideA != insideB)
|
||||
return insideA;
|
||||
|
||||
float dotA = aabbA.furthestPointAlongVector(CGraphics::g_ViewMatrix.basis[1]).dot(CGraphics::g_ViewMatrix.basis[1]);
|
||||
float dotB = aabbB.furthestPointAlongVector(CGraphics::g_ViewMatrix.basis[1]).dot(CGraphics::g_ViewMatrix.basis[1]);
|
||||
float dotA = aabbA.furthestPointAlongVector(
|
||||
CGraphics::g_ViewMatrix.basis[1]).dot(CGraphics::g_ViewMatrix.basis[1]);
|
||||
float dotB = aabbB.furthestPointAlongVector(
|
||||
CGraphics::g_ViewMatrix.basis[1]).dot(CGraphics::g_ViewMatrix.basis[1]);
|
||||
return dotA < dotB;
|
||||
});
|
||||
for (const CFogVolumeListItem& fog : x2ac_fogVolumes)
|
||||
@@ -1050,7 +1054,7 @@ void CBooRenderer::AddParticleGen(const CParticleGen& gen)
|
||||
{
|
||||
if (auto bounds = gen.GetBounds())
|
||||
{
|
||||
zeus::CVector3f pt = bounds.value().closestPointAlongVector(xb0_viewPlane.vec);
|
||||
zeus::CVector3f pt = bounds.value().closestPointAlongVector(xb0_viewPlane.normal());
|
||||
Buckets::Insert(pt, bounds.value(), EDrawableType::Particle, &gen, xb0_viewPlane, 0);
|
||||
}
|
||||
}
|
||||
@@ -1071,7 +1075,7 @@ void CBooRenderer::AddPlaneObject(const void* obj, const zeus::CAABox& aabb, con
|
||||
bool zOnly = plane.normal() == zeus::CVector3f::skUp;
|
||||
bool invert;
|
||||
if (zOnly)
|
||||
invert = CGraphics::g_ViewMatrix.origin.z >= plane.d;
|
||||
invert = CGraphics::g_ViewMatrix.origin.z() >= plane.d();
|
||||
else
|
||||
invert = plane.pointToPlaneDist(CGraphics::g_ViewMatrix.origin) >= 0.f;
|
||||
Buckets::InsertPlaneObject(closeDist, farDist, aabb, invert, plane, zOnly, EDrawableType(type + 2), obj);
|
||||
@@ -1096,8 +1100,7 @@ void CBooRenderer::SetDrawableCallback(TDrawableCallback cb, const void* ctx)
|
||||
void CBooRenderer::SetWorldViewpoint(const zeus::CTransform& xf)
|
||||
{
|
||||
CGraphics::SetViewPointMatrix(xf);
|
||||
xb0_viewPlane.vec = xf.basis[1];
|
||||
xb0_viewPlane.d = xf.basis[1].dot(xf.origin);
|
||||
xb0_viewPlane = zeus::CPlane(xf.basis[1], xf.basis[1].dot(xf.origin));
|
||||
}
|
||||
|
||||
void CBooRenderer::SetPerspective(float fovy, float width, float height, float znear, float zfar)
|
||||
@@ -1474,7 +1477,7 @@ int CBooRenderer::DrawOverlappingWorldModelIDs(int alphaVal, const std::vector<u
|
||||
if (alphaVal > 255)
|
||||
return alphaVal;
|
||||
|
||||
flags.x4_color.a = alphaVal / 255.f;
|
||||
flags.x4_color.a() = alphaVal / 255.f;
|
||||
const CBooModel& model = *item.x10_models[wordModel + j];
|
||||
const_cast<CBooModel&>(model).VerifyCurrentShader(0);
|
||||
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next)
|
||||
@@ -1495,7 +1498,7 @@ void CBooRenderer::DrawOverlappingWorldModelShadows(int alphaVal, const std::vec
|
||||
const zeus::CAABox& aabb, float alpha) const
|
||||
{
|
||||
CModelFlags flags;
|
||||
flags.x4_color.a = alpha;
|
||||
flags.x4_color.a() = alpha;
|
||||
flags.m_extendedShader = EExtendedShader::MorphBallShadow; // Do shadow draw
|
||||
|
||||
u32 curWord = 0;
|
||||
@@ -1517,7 +1520,7 @@ void CBooRenderer::DrawOverlappingWorldModelShadows(int alphaVal, const std::vec
|
||||
if (alphaVal > 255)
|
||||
return;
|
||||
|
||||
flags.x4_color.r = alphaVal / 255.f;
|
||||
flags.x4_color.r() = alphaVal / 255.f;
|
||||
const CBooModel& model = *item.x10_models[wordModel + j];
|
||||
const_cast<CBooModel&>(model).VerifyCurrentShader(0);
|
||||
for (const CBooSurface* surf = model.x38_firstUnsortedSurface; surf; surf = surf->m_next)
|
||||
|
||||
@@ -397,8 +397,8 @@ void CGraphics::FlushProjection()
|
||||
zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point)
|
||||
{
|
||||
zeus::CVector3f projPt = GetPerspectiveProjectionMatrix(false).multiplyOneOverW(point);
|
||||
return {int(projPt.x * g_Viewport.x10_halfWidth) + int(g_Viewport.x10_halfWidth),
|
||||
int(g_Viewport.xc_height) - (int(projPt.y * g_Viewport.x14_halfHeight) +
|
||||
return {int(projPt.x() * g_Viewport.x10_halfWidth) + int(g_Viewport.x10_halfWidth),
|
||||
int(g_Viewport.xc_height) - (int(projPt.y() * g_Viewport.x14_halfHeight) +
|
||||
int(g_Viewport.x14_halfHeight))};
|
||||
}
|
||||
|
||||
@@ -413,14 +413,14 @@ SClipScreenRect CGraphics::ClipScreenRectFromMS(const zeus::CVector3f& p1,
|
||||
SClipScreenRect CGraphics::ClipScreenRectFromVS(const zeus::CVector3f& p1,
|
||||
const zeus::CVector3f& p2)
|
||||
{
|
||||
if (p1.x == 0.f && p1.y == 0.f && p1.z == 0.f)
|
||||
if (p1.x() == 0.f && p1.y() == 0.f && p1.z() == 0.f)
|
||||
return {};
|
||||
if (p2.x == 0.f && p2.y == 0.f && p2.z == 0.f)
|
||||
if (p2.x() == 0.f && p2.y() == 0.f && p2.z() == 0.f)
|
||||
return {};
|
||||
|
||||
if (-p1.z < GetProjectionState().x14_near || -p2.z < GetProjectionState().x14_near)
|
||||
if (-p1.z() < GetProjectionState().x14_near || -p2.z() < GetProjectionState().x14_near)
|
||||
return {};
|
||||
if (-p1.z > GetProjectionState().x18_far || -p2.z > GetProjectionState().x18_far)
|
||||
if (-p1.z() > GetProjectionState().x18_far || -p2.z() > GetProjectionState().x18_far)
|
||||
return {};
|
||||
|
||||
zeus::CVector2i sp1 = ProjectPoint(p1);
|
||||
|
||||
@@ -34,7 +34,7 @@ float CLight::GetIntensity() const
|
||||
if (x1c_type == ELightType::Custom)
|
||||
coef = x30_angleC;
|
||||
const_cast<CLight*>(this)->x48_cachedIntensity =
|
||||
coef * std::max(x18_color.r, std::max(x18_color.g, x18_color.b));
|
||||
coef * std::max(x18_color.r(), std::max(x18_color.g(), x18_color.b()));
|
||||
}
|
||||
return x48_cachedIntensity;
|
||||
}
|
||||
|
||||
@@ -102,11 +102,13 @@ static bool IntersectLines(const zeus::CVector2f& pa1, const zeus::CVector2f& pa
|
||||
const zeus::CVector2f& pb1, const zeus::CVector2f& pb2,
|
||||
zeus::CVector3f& intersect)
|
||||
{
|
||||
float det = (pa1.x - pa2.x) * (pb1.y - pb2.y) - (pa1.y - pa2.y) * (pb1.x - pb2.x);
|
||||
zeus::CVector2f deltaA = pa1 - pa2;
|
||||
zeus::CVector2f deltaB = pb1 - pb2;
|
||||
float det = deltaA.cross(deltaB);
|
||||
if (std::fabs(det) < 0.000001f)
|
||||
return false;
|
||||
float c0 = pa1.x * pa2.y - pa1.y * pa2.x;
|
||||
float c1 = pb1.x * pb2.y - pb1.y * pb2.x;
|
||||
float c0 = pa1.cross(pa2);
|
||||
float c1 = pb1.cross(pb2);
|
||||
intersect = (c0 * (pb1 - pb2) - c1 * (pa1 - pa2)) / det;
|
||||
return true;
|
||||
}
|
||||
@@ -154,13 +156,13 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||
if (!dva.canBeNormalized())
|
||||
dva = {0.f, 1.f};
|
||||
dva = dva.normalized().perpendicularVector() * m_lastWidth;
|
||||
dva.x /= CGraphics::g_ProjAspect;
|
||||
dva.x() /= CGraphics::g_ProjAspect;
|
||||
|
||||
zeus::CVector2f dvb = (projPt - m_lastPos).toVec2f();
|
||||
if (!dvb.canBeNormalized())
|
||||
dvb = {0.f, 1.f};
|
||||
dvb = dvb.normalized().perpendicularVector() * m_lastWidth;
|
||||
dvb.x /= CGraphics::g_ProjAspect;
|
||||
dvb.x() /= CGraphics::g_ProjAspect;
|
||||
|
||||
if (m_textured)
|
||||
{
|
||||
@@ -195,8 +197,8 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||
|
||||
if (good1 && good2)
|
||||
{
|
||||
intersect1.z = m_lastPos.z;
|
||||
intersect2.z = m_lastPos.z;
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||
}
|
||||
@@ -242,8 +244,8 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||
|
||||
if (good1 && good2)
|
||||
{
|
||||
intersect1.z = m_lastPos.z;
|
||||
intersect2.z = m_lastPos.z;
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||
}
|
||||
@@ -263,7 +265,7 @@ void CLineRenderer::AddVertex(const zeus::CVector3f& position, const zeus::CColo
|
||||
if (!dv.canBeNormalized())
|
||||
dv = {0.f, 1.f};
|
||||
dv = dv.normalized().perpendicularVector() * m_lastWidth;
|
||||
dv.x /= CGraphics::g_ProjAspect;
|
||||
dv.x() /= CGraphics::g_ProjAspect;
|
||||
if (m_textured)
|
||||
{
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(m_lastPos + dv, m_lastW), m_lastColor, m_lastUV});
|
||||
@@ -296,13 +298,13 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
|
||||
if (!dva.canBeNormalized())
|
||||
dva = {0.f, 1.f};
|
||||
dva = dva.normalized().perpendicularVector() * m_lastWidth;
|
||||
dva.x /= CGraphics::g_ProjAspect;
|
||||
dva.x() /= CGraphics::g_ProjAspect;
|
||||
|
||||
zeus::CVector2f dvb = (m_firstPos - m_lastPos).toVec2f();
|
||||
if (!dvb.canBeNormalized())
|
||||
dvb = {0.f, 1.f};
|
||||
dvb = dvb.normalized().perpendicularVector() * m_lastWidth;
|
||||
dvb.x /= CGraphics::g_ProjAspect;
|
||||
dvb.x() /= CGraphics::g_ProjAspect;
|
||||
|
||||
zeus::CVector3f intersect1;
|
||||
bool good1 = IntersectLines(m_lastPos2.toVec2f() + dva, m_lastPos.toVec2f() + dva,
|
||||
@@ -320,8 +322,8 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
|
||||
{
|
||||
if (good1 && good2)
|
||||
{
|
||||
intersect1.z = m_lastPos.z;
|
||||
intersect2.z = m_lastPos.z;
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||
}
|
||||
@@ -337,8 +339,8 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
|
||||
{
|
||||
if (good1 && good2)
|
||||
{
|
||||
intersect1.z = m_lastPos.z;
|
||||
intersect2.z = m_lastPos.z;
|
||||
intersect1.z() = float(m_lastPos.z());
|
||||
intersect2.z() = float(m_lastPos.z());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||
}
|
||||
@@ -356,13 +358,13 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
|
||||
if (!dva.canBeNormalized())
|
||||
dva = {0.f, 1.f};
|
||||
dva = dva.normalized().perpendicularVector() * m_firstWidth;
|
||||
dva.x /= CGraphics::g_ProjAspect;
|
||||
dva.x() /= CGraphics::g_ProjAspect;
|
||||
|
||||
zeus::CVector2f dvb = (m_secondPos - m_firstPos).toVec2f();
|
||||
if (!dvb.canBeNormalized())
|
||||
dvb = {0.f, 1.f};
|
||||
dvb = dvb.normalized().perpendicularVector() * m_firstWidth;
|
||||
dvb.x /= CGraphics::g_ProjAspect;
|
||||
dvb.x() /= CGraphics::g_ProjAspect;
|
||||
|
||||
zeus::CVector3f intersect1;
|
||||
bool good1 = IntersectLines(m_lastPos.toVec2f() + dva, m_firstPos.toVec2f() + dva,
|
||||
@@ -380,8 +382,8 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
|
||||
{
|
||||
if (good1 && good2)
|
||||
{
|
||||
intersect1.z = m_firstPos.z;
|
||||
intersect2.z = m_firstPos.z;
|
||||
intersect1.z() = float(m_firstPos.z());
|
||||
intersect2.z() = float(m_firstPos.z());
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor, m_lastUV});
|
||||
g_StaticLineVertsTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor, m_lastUV});
|
||||
}
|
||||
@@ -397,8 +399,8 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
|
||||
{
|
||||
if (good1 && good2)
|
||||
{
|
||||
intersect1.z = m_firstPos.z;
|
||||
intersect2.z = m_firstPos.z;
|
||||
intersect1.z() = float(m_firstPos.z());
|
||||
intersect2.z() = float(m_firstPos.z());
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect1, m_lastW), m_lastColor});
|
||||
g_StaticLineVertsNoTex.push_back({zeus::CVector4f::ToClip(intersect2, m_lastW), m_lastColor});
|
||||
}
|
||||
@@ -418,7 +420,7 @@ void CLineRenderer::Render(const zeus::CColor& moduColor)
|
||||
if (!dv.canBeNormalized())
|
||||
dv = {0.f, 1.f};
|
||||
dv = dv.normalized().perpendicularVector() * m_lastWidth;
|
||||
dv.x /= CGraphics::g_ProjAspect;
|
||||
dv.x() /= CGraphics::g_ProjAspect;
|
||||
if (m_textured)
|
||||
{
|
||||
if (m_mode == EPrimitiveMode::Lines && (m_nextVert & 1))
|
||||
|
||||
@@ -90,7 +90,8 @@ void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurfa
|
||||
else
|
||||
{
|
||||
surfPos = model.x20_aabb.center();
|
||||
surfSize = (model.x20_aabb.max.x - model.x20_aabb.min.x) + (model.x20_aabb.max.y - model.x20_aabb.min.y) * 0.5f;
|
||||
surfSize = (model.x20_aabb.max.x() - model.x20_aabb.min.x()) +
|
||||
(model.x20_aabb.max.y() - model.x20_aabb.min.y()) * 0.5f;
|
||||
}
|
||||
|
||||
if (g_Renderer->x318_24_refectionDirty)
|
||||
@@ -131,11 +132,11 @@ void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurfa
|
||||
float f1 = timeScale * g_TransformedTime;
|
||||
float f2 = timeScale * g_TransformedTime2;
|
||||
mtxsOut[1] = ReflectBaseMtx;
|
||||
mtxsOut[1][0][0] = f1 * v2.x;
|
||||
mtxsOut[1][1][0] = f1 * v2.y;
|
||||
mtxsOut[1][0][0] = f1 * v2.x();
|
||||
mtxsOut[1][1][0] = f1 * v2.y();
|
||||
mtxsOut[1][3][0] = -surfPos.dot(v2) * f1 + 0.5f;
|
||||
mtxsOut[1][2][1] = f2;
|
||||
mtxsOut[1][3][1] = -modelToPlayerLocal.z * f2;
|
||||
mtxsOut[1][3][1] = -modelToPlayerLocal.z() * f2;
|
||||
switch (CGraphics::g_BooPlatform)
|
||||
{
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
@@ -767,28 +768,28 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
case UVAnimation::Mode::MvInvNoTranslation:
|
||||
{
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
texMtxOut.vec[3].w = 1.f;
|
||||
postMtxOut.vec[0].x = 0.5f;
|
||||
postMtxOut.vec[1].y = 0.5f;
|
||||
postMtxOut.vec[3].x = 0.5f;
|
||||
postMtxOut.vec[3].y = 0.5f;
|
||||
texMtxOut.m[3].w() = 1.f;
|
||||
postMtxOut.m[0].x() = 0.5f;
|
||||
postMtxOut.m[1].y() = 0.5f;
|
||||
postMtxOut.m[3].x() = 0.5f;
|
||||
postMtxOut.m[3].y() = 0.5f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::MvInv:
|
||||
{
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
texMtxOut.vec[3] = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix.origin;
|
||||
texMtxOut.vec[3].w = 1.f;
|
||||
postMtxOut.vec[0].x = 0.5f;
|
||||
postMtxOut.vec[1].y = 0.5f;
|
||||
postMtxOut.vec[3].x = 0.5f;
|
||||
postMtxOut.vec[3].y = 0.5f;
|
||||
texMtxOut.m[3] = CGraphics::g_ViewMatrix.inverse() * CGraphics::g_GXModelMatrix.origin;
|
||||
texMtxOut.m[3].w() = 1.f;
|
||||
postMtxOut.m[0].x() = 0.5f;
|
||||
postMtxOut.m[1].y() = 0.5f;
|
||||
postMtxOut.m[3].x() = 0.5f;
|
||||
postMtxOut.m[3].y() = 0.5f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::Scroll:
|
||||
{
|
||||
texMtxOut.vec[3].x = CGraphics::GetSecondsMod900() * anim.vals[2] + anim.vals[0];
|
||||
texMtxOut.vec[3].y = CGraphics::GetSecondsMod900() * anim.vals[3] + anim.vals[1];
|
||||
texMtxOut.m[3].x() = CGraphics::GetSecondsMod900() * anim.vals[2] + anim.vals[0];
|
||||
texMtxOut.m[3].y() = CGraphics::GetSecondsMod900() * anim.vals[3] + anim.vals[1];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::Rotation:
|
||||
@@ -796,35 +797,35 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
float angle = CGraphics::GetSecondsMod900() * anim.vals[1] + anim.vals[0];
|
||||
float acos = std::cos(angle);
|
||||
float asin = std::sin(angle);
|
||||
texMtxOut.vec[0].x = acos;
|
||||
texMtxOut.vec[0].y = asin;
|
||||
texMtxOut.vec[1].x = -asin;
|
||||
texMtxOut.vec[1].y = acos;
|
||||
texMtxOut.vec[3].x = (1.0f - (acos - asin)) * 0.5f;
|
||||
texMtxOut.vec[3].y = (1.0f - (asin + acos)) * 0.5f;
|
||||
texMtxOut.m[0].x() = acos;
|
||||
texMtxOut.m[0].y() = asin;
|
||||
texMtxOut.m[1].x() = -asin;
|
||||
texMtxOut.m[1].y() = acos;
|
||||
texMtxOut.m[3].x() = (1.0f - (acos - asin)) * 0.5f;
|
||||
texMtxOut.m[3].y() = (1.0f - (asin + acos)) * 0.5f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::HStrip:
|
||||
{
|
||||
float value = anim.vals[0] * anim.vals[2] * (anim.vals[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut.vec[3].x = (float)(short)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
texMtxOut.m[3].x() = (float)(short)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::VStrip:
|
||||
{
|
||||
float value = anim.vals[0] * anim.vals[2] * (anim.vals[3] + CGraphics::GetSecondsMod900());
|
||||
texMtxOut.vec[3].y = (float)(short)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
texMtxOut.m[3].y() = (float)(short)(anim.vals[1] * fmod(value, 1.0f)) * anim.vals[2];
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::Model:
|
||||
{
|
||||
texMtxOut = CGraphics::g_GXModelMatrix.toMatrix4f();
|
||||
texMtxOut.vec[3].zeroOut();
|
||||
postMtxOut.vec[0].x = 0.5f;
|
||||
postMtxOut.vec[1].y = 0.f;
|
||||
postMtxOut.vec[2].y = 0.5f;
|
||||
postMtxOut.vec[3].x = CGraphics::g_GXModelMatrix.origin.x * 0.05f;
|
||||
postMtxOut.vec[3].y = CGraphics::g_GXModelMatrix.origin.y * 0.05f;
|
||||
texMtxOut.m[3].zeroOut();
|
||||
postMtxOut.m[0].x() = 0.5f;
|
||||
postMtxOut.m[1].y() = 0.f;
|
||||
postMtxOut.m[2].y() = 0.5f;
|
||||
postMtxOut.m[3].x() = CGraphics::g_GXModelMatrix.origin.x() * 0.05f;
|
||||
postMtxOut.m[3].y() = CGraphics::g_GXModelMatrix.origin.y() * 0.05f;
|
||||
break;
|
||||
}
|
||||
case UVAnimation::Mode::CylinderEnvironment:
|
||||
@@ -832,9 +833,9 @@ void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimati
|
||||
texMtxOut = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||
|
||||
const zeus::CVector3f& viewOrigin = CGraphics::g_ViewMatrix.origin;
|
||||
float xy = (viewOrigin.x + viewOrigin.y) * 0.025f * anim.vals[1];
|
||||
float xy = (viewOrigin.x() + viewOrigin.y()) * 0.025f * anim.vals[1];
|
||||
xy = (xy - (int)xy);
|
||||
float z = (viewOrigin.z) * 0.05f * anim.vals[1];
|
||||
float z = (viewOrigin.z()) * 0.05f * anim.vals[1];
|
||||
z = (z - (int)z);
|
||||
|
||||
float halfA = anim.vals[0] * 0.5f;
|
||||
@@ -879,12 +880,8 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
|
||||
{
|
||||
/* Special matrices for MorphBall shadow rendering */
|
||||
zeus::CMatrix4f texMtx =
|
||||
(zeus::CTransform::Scale(1.f / (flags.mbShadowBox.max.x - flags.mbShadowBox.min.x),
|
||||
1.f / (flags.mbShadowBox.max.y - flags.mbShadowBox.min.y),
|
||||
1.f / (flags.mbShadowBox.max.z - flags.mbShadowBox.min.z)) *
|
||||
zeus::CTransform::Translate(-flags.mbShadowBox.min.x,
|
||||
-flags.mbShadowBox.min.y,
|
||||
-flags.mbShadowBox.min.z) * CGraphics::g_GXModelView).toMatrix4f();
|
||||
(zeus::CTransform::Scale(1.f / (flags.mbShadowBox.max - flags.mbShadowBox.min)) *
|
||||
zeus::CTransform::Translate(-flags.mbShadowBox.min) * CGraphics::g_GXModelView).toMatrix4f();
|
||||
for (const MaterialSet::Material& mat : matSet->materials)
|
||||
{
|
||||
(void)mat;
|
||||
@@ -907,11 +904,11 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
|
||||
zeus::CTransform::Translate(-aabb.min) * xf;
|
||||
zeus::CMatrix4f texMtx = xf.toMatrix4f();
|
||||
zeus::CMatrix4f post0 = DisintegratePost;
|
||||
post0[3].x = flags.addColor.a;
|
||||
post0[3].y = 6.f * -(1.f - flags.addColor.a) + 1.f;
|
||||
post0[3].x() = flags.addColor.a();
|
||||
post0[3].y() = 6.f * -(1.f - flags.addColor.a()) + 1.f;
|
||||
zeus::CMatrix4f post1 = DisintegratePost;
|
||||
post1[3].x = -0.85f * flags.addColor.a - 0.15f;
|
||||
post1[3].y = post0[3].y;
|
||||
post1[3].x() = -0.85f * flags.addColor.a() - 0.15f;
|
||||
post1[3].y() = float(post0[3].y());
|
||||
/* Special matrices for disintegration rendering */
|
||||
for (const MaterialSet::Material& mat : matSet->materials)
|
||||
{
|
||||
@@ -941,10 +938,10 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
|
||||
*/
|
||||
|
||||
zeus::CMatrix4f& postMtxOut = (*specialMtxOut)[1];
|
||||
postMtxOut.vec[0].x = 0.5f;
|
||||
postMtxOut.vec[1].y = 0.5f;
|
||||
postMtxOut.vec[3].x = 0.5f;
|
||||
postMtxOut.vec[3].y = 0.5f;
|
||||
postMtxOut.m[0].x() = 0.5f;
|
||||
postMtxOut.m[1].y() = 0.5f;
|
||||
postMtxOut.m[3].x() = 0.5f;
|
||||
postMtxOut.m[3].y() = 0.5f;
|
||||
}
|
||||
else if (flags.m_extendedShader == EExtendedShader::WorldShadow)
|
||||
{
|
||||
@@ -953,14 +950,14 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
|
||||
|
||||
zeus::CMatrix4f mat = g_shadowTexXf.toMatrix4f();
|
||||
zeus::CMatrix4f& texMtxOut = (*specialMtxOut)[0];
|
||||
texMtxOut[0][0] = mat[0][0];
|
||||
texMtxOut[1][0] = mat[1][0];
|
||||
texMtxOut[2][0] = mat[2][0];
|
||||
texMtxOut[3][0] = mat[3][0];
|
||||
texMtxOut[0][1] = mat[0][2];
|
||||
texMtxOut[1][1] = mat[1][2];
|
||||
texMtxOut[2][1] = mat[2][2];
|
||||
texMtxOut[3][1] = mat[3][2];
|
||||
texMtxOut[0][0] = float(mat[0][0]);
|
||||
texMtxOut[1][0] = float(mat[1][0]);
|
||||
texMtxOut[2][0] = float(mat[2][0]);
|
||||
texMtxOut[3][0] = float(mat[3][0]);
|
||||
texMtxOut[0][1] = float(mat[0][2]);
|
||||
texMtxOut[1][1] = float(mat[1][2]);
|
||||
texMtxOut[2][1] = float(mat[2][2]);
|
||||
texMtxOut[3][1] = float(mat[3][2]);
|
||||
}
|
||||
|
||||
for (const MaterialSet::Material& mat : matSet->materials)
|
||||
@@ -1146,8 +1143,8 @@ boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFl
|
||||
{
|
||||
CModelShaders::MBShadowUniform& shadowOut = *reinterpret_cast<CModelShaders::MBShadowUniform*>(dataCur);
|
||||
shadowOut.shadowUp = CGraphics::g_GXModelView * zeus::CVector3f::skUp;
|
||||
shadowOut.shadowUp.w = flags.x4_color.a;
|
||||
shadowOut.shadowId = flags.x4_color.r;
|
||||
shadowOut.shadowUp.w() = flags.x4_color.a();
|
||||
shadowOut.shadowId = flags.x4_color.r();
|
||||
}
|
||||
else if (flags.m_extendedShader == EExtendedShader::Disintegrate)
|
||||
{
|
||||
@@ -1470,12 +1467,12 @@ void CModel::ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBu
|
||||
{
|
||||
const std::pair<zeus::CVector3f, zeus::CVector3f>& avn = vn[i];
|
||||
float* floats = reinterpret_cast<float*>(data + GetPoolVertexOffset(i));
|
||||
floats[0] = avn.first.x;
|
||||
floats[1] = avn.first.y;
|
||||
floats[2] = avn.first.z;
|
||||
floats[3] = avn.second.x;
|
||||
floats[4] = avn.second.y;
|
||||
floats[5] = avn.second.z;
|
||||
floats[0] = avn.first.x();
|
||||
floats[1] = avn.first.y();
|
||||
floats[2] = avn.first.z();
|
||||
floats[3] = avn.second.x();
|
||||
floats[4] = avn.second.y();
|
||||
floats[5] = avn.second.z();
|
||||
}
|
||||
vertBuf->unmap();
|
||||
}
|
||||
|
||||
@@ -44,39 +44,39 @@ s32 CPVSVisOctree::IterateSearch(u8 nodeData, const zeus::CVector3f& tp) const
|
||||
zeus::CVector3f newMax;
|
||||
bool highFlags[3];
|
||||
|
||||
if (tp.x > newMin.x)
|
||||
if (tp.x() > newMin.x())
|
||||
{
|
||||
newMax.x = x2c_searchAabb.max.x;
|
||||
newMax.x() = x2c_searchAabb.max.x();
|
||||
highFlags[0] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newMax.x = newMin.x;
|
||||
newMin.x = x2c_searchAabb.min.x;
|
||||
newMax.x() = float(newMin.x());
|
||||
newMin.x() = float(x2c_searchAabb.min.x());
|
||||
highFlags[0] = false;
|
||||
}
|
||||
|
||||
if (tp.y > newMin.y)
|
||||
if (tp.y() > newMin.y())
|
||||
{
|
||||
newMax.y = x2c_searchAabb.max.y;
|
||||
newMax.y() = float(x2c_searchAabb.max.y());
|
||||
highFlags[1] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newMax.y = newMin.y;
|
||||
newMin.y = x2c_searchAabb.min.y;
|
||||
newMax.y() = float(newMin.y());
|
||||
newMin.y() = float(x2c_searchAabb.min.y());
|
||||
highFlags[1] = false;
|
||||
}
|
||||
|
||||
if (tp.z > newMin.z)
|
||||
if (tp.z() > newMin.z())
|
||||
{
|
||||
newMax.z = x2c_searchAabb.max.z;
|
||||
newMax.z() = float(x2c_searchAabb.max.z());
|
||||
highFlags[2] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newMax.z = newMin.z;
|
||||
newMin.z = x2c_searchAabb.min.z;
|
||||
newMax.z() = float(newMin.z());
|
||||
newMin.z() = float(x2c_searchAabb.min.z());
|
||||
highFlags[2] = false;
|
||||
}
|
||||
|
||||
@@ -89,18 +89,18 @@ s32 CPVSVisOctree::IterateSearch(u8 nodeData, const zeus::CVector3f& tp) const
|
||||
zeus::CAABox& newSearch = const_cast<zeus::CAABox&>(x2c_searchAabb);
|
||||
if (nodeData & 0x1)
|
||||
{
|
||||
newSearch.min.x = newMin.x;
|
||||
newSearch.max.x = newMax.x;
|
||||
newSearch.min.x() = float(newMin.x());
|
||||
newSearch.max.x() = float(newMax.x());
|
||||
}
|
||||
if (nodeData & 0x2)
|
||||
{
|
||||
newSearch.min.y = newMin.y;
|
||||
newSearch.max.y = newMax.y;
|
||||
newSearch.min.y() = float(newMin.y());
|
||||
newSearch.max.y() = float(newMax.y());
|
||||
}
|
||||
if (nodeData & 0x4)
|
||||
{
|
||||
newSearch.min.z = newMin.z;
|
||||
newSearch.max.z = newMax.z;
|
||||
newSearch.min.z() = float(newMin.z());
|
||||
newSearch.max.z() = float(newMax.z());
|
||||
}
|
||||
|
||||
// Branch node - calculate next relative pointer
|
||||
|
||||
@@ -191,7 +191,7 @@ u32 CRainSplashGenerator::GetNextBestPt(u32 pt, const std::vector<std::pair<zeus
|
||||
float distSq = (refVert.first - vert.first).magSquared();
|
||||
if (distSq > maxDist &&
|
||||
vert.second.dot(zeus::CVector3f::skUp) >= 0.f &&
|
||||
(vert.first.z <= 0.f || vert.first.z > minZ))
|
||||
(vert.first.z() <= 0.f || vert.first.z() > minZ))
|
||||
{
|
||||
nextPt = idx;
|
||||
maxDist = distSq;
|
||||
|
||||
@@ -18,16 +18,16 @@ zeus::CAABox CSimpleShadow::GetMaxShadowBox(const zeus::CAABox& aabb) const
|
||||
float extent = x34_radius * x30_scale;
|
||||
zeus::CVector3f center = aabb.center();
|
||||
zeus::CAABox expandedAABB = aabb;
|
||||
expandedAABB.accumulateBounds({center.x + extent, center.y + extent, center.z - GetMaxObjectHeight()});
|
||||
expandedAABB.accumulateBounds({center.x - extent, center.y - extent, center.z - GetMaxObjectHeight()});
|
||||
expandedAABB.accumulateBounds({center.x() + extent, center.y() + extent, center.z() - GetMaxObjectHeight()});
|
||||
expandedAABB.accumulateBounds({center.x() - extent, center.y() - extent, center.z() - GetMaxObjectHeight()});
|
||||
return expandedAABB;
|
||||
}
|
||||
|
||||
zeus::CAABox CSimpleShadow::GetBounds() const
|
||||
{
|
||||
float extent = x34_radius * x30_scale;
|
||||
return {{x0_xf.origin.x - extent, x0_xf.origin.y - extent, x0_xf.origin.z - extent},
|
||||
{x0_xf.origin.x + extent, x0_xf.origin.y + extent, x0_xf.origin.z + extent}};
|
||||
return {{x0_xf.origin.x() - extent, x0_xf.origin.y() - extent, x0_xf.origin.z() - extent},
|
||||
{x0_xf.origin.x() + extent, x0_xf.origin.y() + extent, x0_xf.origin.z() + extent}};
|
||||
}
|
||||
|
||||
void CSimpleShadow::Render(const TLockedToken<CTexture>& tex) const
|
||||
@@ -55,7 +55,7 @@ void CSimpleShadow::Render(const TLockedToken<CTexture>& tex) const
|
||||
void CSimpleShadow::Calculate(const zeus::CAABox& aabb, const zeus::CTransform& xf, const CStateManager& mgr)
|
||||
{
|
||||
x48_24_collision = false;
|
||||
float halfHeight = (aabb.max.z - aabb.min.z) * 0.5f;
|
||||
float halfHeight = (aabb.max.z() - aabb.min.z()) * 0.5f;
|
||||
zeus::CVector3f pos = xf.origin + zeus::CVector3f(0.f, 0.f, halfHeight);
|
||||
CRayCastResult res = mgr.RayStaticIntersection(pos, zeus::CVector3f::skDown, x40_maxObjHeight,
|
||||
CMaterialFilter::MakeExclude({EMaterialTypes::SeeThrough}));
|
||||
@@ -88,8 +88,8 @@ void CSimpleShadow::Calculate(const zeus::CAABox& aabb, const zeus::CTransform&
|
||||
x0_xf.origin = res.GetPlane().normal() * x44_displacement + res.GetPoint();
|
||||
if (x48_25_alwaysCalculateRadius || !x48_26_radiusCalculated)
|
||||
{
|
||||
float xExtent = aabb.max.x - aabb.min.x;
|
||||
float yExtent = aabb.max.y - aabb.min.y;
|
||||
float xExtent = aabb.max.x() - aabb.min.x();
|
||||
float yExtent = aabb.max.y() - aabb.min.y();
|
||||
x34_radius = std::sqrt(xExtent * xExtent + yExtent * yExtent) * 0.5f;
|
||||
x48_26_radiusCalculated = true;
|
||||
}
|
||||
|
||||
@@ -39,45 +39,45 @@ void CAABoxShader::setAABB(const zeus::CAABox& aabb)
|
||||
{
|
||||
zeus::CVector3f vboData[] =
|
||||
{
|
||||
{aabb.max.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.max.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||
|
||||
{aabb.min.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.max.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
|
||||
|
||||
{aabb.min.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.min.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.min.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.max.z()},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
||||
|
||||
{aabb.min.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||
|
||||
{aabb.min.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.min.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.max.z},
|
||||
{aabb.min.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.max.x, aabb.max.y, aabb.max.z},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.max.z()},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.max.z()},
|
||||
|
||||
{aabb.min.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.max.x, aabb.min.y, aabb.min.z},
|
||||
{aabb.min.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.max.x, aabb.max.y, aabb.min.z},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.min.y(), aabb.min.z()},
|
||||
{aabb.min.x(), aabb.max.y(), aabb.min.z()},
|
||||
{aabb.max.x(), aabb.max.y(), aabb.min.z()},
|
||||
};
|
||||
|
||||
m_vbo->load(vboData, sizeof(zeus::CVector3f) * 34);
|
||||
|
||||
@@ -64,10 +64,10 @@ CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
|
||||
|
||||
void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect)
|
||||
{
|
||||
m_uniform.m_matrix[0][0] = rect.size.x * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y * 2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y * 2.f - 1.f;
|
||||
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y() * 2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
|
||||
m_uniform.m_color = color;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
@@ -85,7 +85,7 @@ void CWideScreenFilter::draw(const zeus::CColor& color, float t)
|
||||
delta /= float(g_Viewport.xc_height);
|
||||
zeus::CRectangle rect(0.f, 0.f, 1.f, delta);
|
||||
m_bottom.draw(color, rect);
|
||||
rect.position.y = 1.f - delta;
|
||||
rect.position.y() = 1.f - delta;
|
||||
m_top.draw(color, rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ void CEnvFxShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& c
|
||||
auto iBufInfo = grid.m_instBuf.getBufferInfo();
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {uBufInfo.first.get(),
|
||||
fxMgr.m_fogUniformBuf.get()};
|
||||
size_t ubufOffsets[] = {uBufInfo.second, 0};
|
||||
size_t ubufOffsets[] = {size_t(uBufInfo.second), 0};
|
||||
size_t ubufSizes[] = {sizeof(CEnvFxShaders::Uniform), sizeof(CGraphics::g_Fog)};
|
||||
boo::PipelineStage uniformStages[] = {boo::PipelineStage::Vertex, boo::PipelineStage::Fragment};
|
||||
boo::ObjToken<boo::ITexture> textures[] = {fxMgr.xb74_txtrSnowFlake->GetBooTexture(),
|
||||
|
||||
@@ -264,23 +264,23 @@ void CFluidPlaneShader::prepareDraw(const RenderSetupInfo& info,
|
||||
continue;
|
||||
}
|
||||
zeus::CVector3f localPos = ripple.GetCenter() - waterCenter;
|
||||
rOut.center.x = localPos.x;
|
||||
rOut.center.y = localPos.y;
|
||||
rOut.center.z = ripple.GetTime() * ripple.GetOOTimeFalloff();
|
||||
rOut.center.w = ripple.GetOODistanceFalloff();
|
||||
rOut.params.x = ripple.GetAmplitude();
|
||||
rOut.params.y = ripple.GetPhase();
|
||||
rOut.params.z = (1.f - ripple.GetTime() * ripple.GetOOTimeFalloff() *
|
||||
ripple.GetOOTimeFalloff()) * ripple.GetFrequency();
|
||||
rOut.center.x() = float(localPos.x());
|
||||
rOut.center.y() = float(localPos.y());
|
||||
rOut.center.z() = ripple.GetTime() * ripple.GetOOTimeFalloff();
|
||||
rOut.center.w() = ripple.GetOODistanceFalloff();
|
||||
rOut.params.x() = ripple.GetAmplitude();
|
||||
rOut.params.y() = ripple.GetPhase();
|
||||
rOut.params.z() = (1.f - ripple.GetTime() * ripple.GetOOTimeFalloff() *
|
||||
ripple.GetOOTimeFalloff()) * ripple.GetFrequency();
|
||||
}
|
||||
uni.m_colorMul = colorMul;
|
||||
uni.m_pad[0].x = rippleNormResolution;
|
||||
uni.m_pad[0].x() = rippleNormResolution;
|
||||
uni.m_lighting.ActivateLights(info.lights);
|
||||
for (i=0 ; i<3 ; ++i)
|
||||
uni.m_lighting.colorRegs[i] = info.kColors[i];
|
||||
uni.m_lighting.mulColor = info.kColors[3];
|
||||
uni.m_lighting.fog = CGraphics::g_Fog;
|
||||
uni.m_pad2.x = info.indScale;
|
||||
uni.m_pad2.x() = info.indScale;
|
||||
m_uniBuf->unmap();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& c
|
||||
vec.normalize();
|
||||
vec *= zeus::CVector2f(std::sqrt(mag));
|
||||
}
|
||||
data[y][x][0] = zeus::clamp(0, int((((vec.x / 2.f + 0.5f) - x / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
|
||||
data[y][x][1] = zeus::clamp(0, int((((vec.y / 2.f + 0.5f) - y / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
|
||||
data[y][x][0] = zeus::clamp(0, int((((vec.x() / 2.f + 0.5f) - x / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
|
||||
data[y][x][1] = zeus::clamp(0, int((((vec.y() / 2.f + 0.5f) - y / float(WARP_RAMP_RES)) + 0.5f) * 255), 255);
|
||||
}
|
||||
}
|
||||
m_warpTex = ctx.newStaticTexture(WARP_RAMP_RES+1, WARP_RAMP_RES+1, 1,
|
||||
@@ -132,14 +132,14 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt)
|
||||
|
||||
/* Transform UV coordinates of rectangle within viewport and sampled scene texels (clamped to viewport bounds) */
|
||||
zeus::CVector2f vp{float(CGraphics::g_CroppedViewport.xc_width), float(CGraphics::g_CroppedViewport.x10_height)};
|
||||
m_uniform.m_matrix[0][0] = clipRect.xc_width / vp.x;
|
||||
m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y;
|
||||
m_uniform.m_matrix[3][0] = pt.x + (1.f / vp.x);
|
||||
m_uniform.m_matrix[3][1] = pt.y + (1.f / vp.y);
|
||||
m_uniform.m_matrix[0][0] = clipRect.xc_width / vp.x();
|
||||
m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y();
|
||||
m_uniform.m_matrix[3][0] = pt.x() + (1.f / vp.x());
|
||||
m_uniform.m_matrix[3][1] = pt.y() + (1.f / vp.y());
|
||||
if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL)
|
||||
m_uniform.m_matrix[3][2] = pt.z * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][2] = pt.z() * 2.f - 1.f;
|
||||
else
|
||||
m_uniform.m_matrix[3][2] = pt.z;
|
||||
m_uniform.m_matrix[3][2] = pt.z();
|
||||
|
||||
if (clipRect.x4_left)
|
||||
{
|
||||
@@ -161,9 +161,9 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt)
|
||||
clipRect.x8_top = g_Viewport.xc_height - clipRect.x10_height - clipRect.x8_top;
|
||||
CGraphics::ResolveSpareTexture(clipRect);
|
||||
|
||||
m_uniform.m_strength.x = m_uniform.m_matrix[0][0] * m_strength * 0.5f *
|
||||
(clipRect.x10_height / float(clipRect.xc_width));
|
||||
m_uniform.m_strength.y = m_uniform.m_matrix[1][1] * m_strength * 0.5f;
|
||||
m_uniform.m_strength.x() = m_uniform.m_matrix[0][0] * m_strength * 0.5f *
|
||||
(clipRect.x10_height / float(clipRect.xc_width));
|
||||
m_uniform.m_strength.y() = m_uniform.m_matrix[1][1] * m_strength * 0.5f;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
|
||||
@@ -66,22 +66,22 @@ void CTextSupportShader::ImageInstance::SetMetrics(const CFontImageDef& imgDef,
|
||||
if (imgDef.x4_texs.size())
|
||||
{
|
||||
const CTexture& tex = *imgDef.x4_texs[0].GetObj();
|
||||
imgSize.assign(tex.GetWidth() * imgDef.x14_cropFactor.x,
|
||||
tex.GetHeight() * imgDef.x14_cropFactor.y);
|
||||
imgSize.assign(tex.GetWidth() * imgDef.x14_cropFactor.x(),
|
||||
tex.GetHeight() * imgDef.x14_cropFactor.y());
|
||||
}
|
||||
zeus::CVector2f cropPad = imgDef.x14_cropFactor * 0.5f;
|
||||
|
||||
m_pos[0].assign(offset.x, 0.f, offset.y);
|
||||
m_uv[0].assign(0.5f - cropPad.x, 0.5f + cropPad.y);
|
||||
m_uv[0].assign(0.5f - cropPad.x(), 0.5f + cropPad.y());
|
||||
|
||||
m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y);
|
||||
m_uv[1].assign(0.5f + cropPad.x, 0.5f + cropPad.y);
|
||||
m_pos[1].assign(offset.x + imgSize.x(), 0.f, offset.y);
|
||||
m_uv[1].assign(0.5f + cropPad.x(), 0.5f + cropPad.y());
|
||||
|
||||
m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y);
|
||||
m_uv[2].assign(0.5f - cropPad.x, 0.5f - cropPad.y);
|
||||
m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y());
|
||||
m_uv[2].assign(0.5f - cropPad.x(), 0.5f - cropPad.y());
|
||||
|
||||
m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y);
|
||||
m_uv[3].assign(0.5f + cropPad.x, 0.5f - cropPad.y);
|
||||
m_pos[3].assign(offset.x + imgSize.x(), 0.f, offset.y + imgSize.y());
|
||||
m_uv[3].assign(0.5f + cropPad.x(), 0.5f - cropPad.y());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -231,17 +231,17 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z
|
||||
|
||||
if (!m_flipRect)
|
||||
{
|
||||
m_uniform.m_matrix[0][0] = rect.size.x * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y * 2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y * 2.f - 1.f;
|
||||
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y() * 2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_uniform.m_matrix[0][0] = rect.size.x * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y * -2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y * -2.f + 1.f;
|
||||
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
|
||||
m_uniform.m_matrix[1][1] = rect.size.y() * -2.f;
|
||||
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
|
||||
m_uniform.m_matrix[3][1] = rect.position.y() * -2.f + 1.f;
|
||||
}
|
||||
m_uniform.m_color = color;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
Reference in New Issue
Block a user