mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 14:24:56 +00:00
SIMD refactor
This commit is contained in:
@@ -623,8 +623,8 @@ void CAutoMapper::ProcessMapRotateInput(const CFinalInput& input, const CStateMa
|
||||
float deltaFrames = input.DeltaTime() * 60.f;
|
||||
SetShouldRotatingSoundBePlaying(true);
|
||||
zeus::CEulerAngles eulers(xa8_renderStates[0].x8_camOrientation);
|
||||
zeus::CRelAngle angX(eulers.x);
|
||||
zeus::CRelAngle angZ(eulers.z);
|
||||
zeus::CRelAngle angX(eulers.x());
|
||||
zeus::CRelAngle angZ(eulers.z());
|
||||
|
||||
float dt = deltaFrames * g_tweakAutoMapper->GetCamRotateDegreesPerFrame();
|
||||
|
||||
@@ -892,7 +892,7 @@ zeus::CQuaternion CAutoMapper::GetMiniMapCameraOrientation(const CStateManager&
|
||||
{
|
||||
const CGameCamera* cam = stateMgr.GetCameraManager()->GetCurrentCamera(stateMgr);
|
||||
zeus::CEulerAngles camAngles(zeus::CQuaternion(cam->GetTransform().buildMatrix3f()));
|
||||
float rotMod = -(std::floor(camAngles.z * 0.15915494f) * 2.f * M_PIF - camAngles.z);
|
||||
float rotMod = -(std::floor(camAngles.z() / (2.f * M_PIF)) * 2.f * M_PIF - camAngles.z());
|
||||
if (rotMod < 0.f)
|
||||
rotMod += 2.f * M_PIF;
|
||||
|
||||
@@ -1035,9 +1035,9 @@ float CAutoMapper::GetDesiredMiniMapCameraDistance(const CStateManager& mgr) con
|
||||
|
||||
zeus::CVector3f xfPoint = mapa->GetAreaPostTransform(*x24_world, xa0_curAreaId) * mapa->GetAreaCenterPoint();
|
||||
zeus::CVector3f maxMargin;
|
||||
maxMargin.x = std::max(xfPoint.x - aabb.min.x, aabb.max.x - xfPoint.x);
|
||||
maxMargin.y = std::max(xfPoint.y - aabb.min.y, aabb.max.y - xfPoint.y);
|
||||
maxMargin.z = std::max(xfPoint.z - aabb.min.z, aabb.max.z - xfPoint.z);
|
||||
maxMargin.x() = std::max(xfPoint.x() - aabb.min.x(), aabb.max.x() - xfPoint.x());
|
||||
maxMargin.y() = std::max(xfPoint.y() - aabb.min.y(), aabb.max.y() - xfPoint.y());
|
||||
maxMargin.z() = std::max(xfPoint.z() - aabb.min.z(), aabb.max.z() - xfPoint.z());
|
||||
zeus::CVector3f extent = mapa->GetBoundingBox().max - mapa->GetBoundingBox().min;
|
||||
|
||||
return (0.5f * (0.5f * extent.magnitude()) + 0.5f * maxMargin.magnitude()) *
|
||||
@@ -1589,7 +1589,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
|
||||
float func = zeus::clamp(0.f, 0.5f * (1.f + std::sin(5.f * CGraphics::GetSecondsMod900() - (M_PIF / 2.f))), 1.f);
|
||||
float scale = std::min(0.6f * g_tweakAutoMapper->GetMaxCamDist() / g_tweakAutoMapper->GetMinCamDist(), objectScale);
|
||||
zeus::CEulerAngles eulers(mgr.GetCameraManager()->GetCurrentCameraTransform(mgr));
|
||||
zeus::CRelAngle angle(eulers.z);
|
||||
zeus::CRelAngle angle(eulers.z());
|
||||
zeus::CTransform playerXf(zeus::CMatrix3f::RotateZ(angle),
|
||||
CMapArea::GetAreaPostTranslate(*x24_world, mgr.GetNextAreaId()) + mgr.GetPlayer().GetTranslation());
|
||||
CGraphics::SetModelMatrix(mapXf * playerXf * zeus::CTransform::Scale(scale * (0.25f * func + 0.75f)));
|
||||
@@ -1600,7 +1600,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
|
||||
alpha = xa8_renderStates[0].x34_alphaSurfaceVisited;
|
||||
alpha *= mapAlpha;
|
||||
zeus::CColor modColor = g_tweakAutoMapper->GetMiniMapSamusModColor();
|
||||
modColor.a *= alpha;
|
||||
modColor.a() *= alpha;
|
||||
CModelFlags flags(5, 0, 8 | 1, modColor); /* Depth GEqual */
|
||||
flags.m_extendedShader = EExtendedShader::DepthGEqualNoZWrite;
|
||||
x30_miniMapSamus->Draw(flags);
|
||||
@@ -1651,7 +1651,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
|
||||
alpha *= xa8_renderStates[0].x34_alphaSurfaceVisited;
|
||||
alpha *= mapAlpha;
|
||||
zeus::CColor color = zeus::CColor::skWhite;
|
||||
color.a = alpha;
|
||||
color.a() = alpha;
|
||||
filter.drawVerts(color, verts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,10 +294,10 @@ void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::C
|
||||
|
||||
Instance& instance = const_cast<Instance&>(m_instances[instIdx]);
|
||||
|
||||
if (surfColor.a)
|
||||
if (surfColor.a())
|
||||
instance.m_surfacePrims.draw(surfColor, m_primStart, m_primCount);
|
||||
|
||||
if (lineColor.a)
|
||||
if (lineColor.a())
|
||||
{
|
||||
bool draw2 = lineWidth > 1.f;
|
||||
athena::io::MemoryReader r(x1c_outlineOffset, INT_MAX);
|
||||
@@ -306,7 +306,7 @@ void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::C
|
||||
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
|
||||
zeus::CColor color = lineColor;
|
||||
if (draw2)
|
||||
color.a *= 0.5f;
|
||||
color.a() *= 0.5f;
|
||||
float width = lineWidth;
|
||||
|
||||
auto primIt = linePrims.begin();
|
||||
|
||||
@@ -66,16 +66,16 @@ void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3
|
||||
if (w == parms.GetFocusWorldIndex())
|
||||
{
|
||||
surfColor = data.GetSurfaceColorSelected();
|
||||
surfColor.a *= parms.GetAlpha();
|
||||
surfColor.a() *= parms.GetAlpha();
|
||||
outlineColor = data.GetOutlineColorSelected();
|
||||
outlineColor.a *= parms.GetAlpha();
|
||||
outlineColor.a() *= parms.GetAlpha();
|
||||
}
|
||||
else
|
||||
{
|
||||
surfColor = data.GetSurfaceColorUnselected();
|
||||
surfColor.a *= parms.GetAlpha();
|
||||
surfColor.a() *= parms.GetAlpha();
|
||||
outlineColor = data.GetSurfaceColorUnselected();
|
||||
outlineColor.a *= parms.GetAlpha();
|
||||
outlineColor.a() *= parms.GetAlpha();
|
||||
}
|
||||
|
||||
for (int h=0 ; h<data.GetNumMapAreaDatas() ; ++h)
|
||||
@@ -85,7 +85,7 @@ void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3
|
||||
{
|
||||
const CMapArea::CMapAreaSurface& surf = x4_hexagonToken->GetSurface(s);
|
||||
zeus::CVector3f centerPos = hexXf * surf.GetCenterPosition();
|
||||
sortInfos.emplace_back(centerPos.y, w, h, s, surfColor, outlineColor);
|
||||
sortInfos.emplace_back(centerPos.y(), w, h, s, surfColor, outlineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,11 +109,11 @@ void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3
|
||||
surfColor = zeus::CColor::lerp(g_tweakAutoMapper->GetSurfaceSelectVisitedColor(),
|
||||
g_tweakAutoMapper->GetAreaFlashPulseColor(),
|
||||
parms.GetFlashPulse());
|
||||
surfColor.a = info.GetSurfaceColor().a;
|
||||
surfColor.a() = info.GetSurfaceColor().a();
|
||||
outlineColor = zeus::CColor::lerp(g_tweakAutoMapper->GetOutlineSelectVisitedColor(),
|
||||
g_tweakAutoMapper->GetAreaFlashPulseColor(),
|
||||
parms.GetFlashPulse());
|
||||
outlineColor.a = info.GetOutlineColor().a;
|
||||
outlineColor.a() = info.GetOutlineColor().a();
|
||||
}
|
||||
|
||||
zeus::CTransform hexXf = mwData.GetMapAreaData(info.GetAreaIndex());
|
||||
|
||||
@@ -311,9 +311,9 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre
|
||||
else
|
||||
{
|
||||
finalSurfColor = *surfaceColor;
|
||||
finalSurfColor.a = surfDepth * alphaSurf;
|
||||
finalSurfColor.a() = surfDepth * alphaSurf;
|
||||
finalOutlineColor = *outlineColor;
|
||||
finalOutlineColor.a = outlineDepth * alphaOutline;
|
||||
finalOutlineColor.a() = outlineDepth * alphaOutline;
|
||||
}
|
||||
|
||||
if ((selArea != playerArea || parms.GetHintAreaFlashIntensity() == 0.f) &&
|
||||
@@ -331,7 +331,7 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre
|
||||
{
|
||||
const CMapArea::CMapAreaSurface& surf = mapa->GetSurface(i);
|
||||
zeus::CVector3f pos = modelView * surf.GetCenterPosition();
|
||||
sortInfos.emplace_back(pos.y, thisArea, CMapObjectSortInfo::EObjectCode::Surface, i,
|
||||
sortInfos.emplace_back(pos.y(), thisArea, CMapObjectSortInfo::EObjectCode::Surface, i,
|
||||
finalSurfColor, finalOutlineColor);
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre
|
||||
zeus::CVector3f center = obj.BuildSurfaceCenterPoint(s);
|
||||
zeus::CVector3f pos = modelView *
|
||||
(CMapArea::GetAreaPostTranslate(parms.GetWorld(), thisArea) + center);
|
||||
sortInfos.emplace_back(pos.y, thisArea, CMapObjectSortInfo::EObjectCode::DoorSurface, si+s,
|
||||
sortInfos.emplace_back(pos.y(), thisArea, CMapObjectSortInfo::EObjectCode::DoorSurface, si+s,
|
||||
zeus::CColor{1.f, 0.f, 1.f, 1.f}, zeus::CColor{1.f, 0.f, 1.f, 1.f});
|
||||
}
|
||||
continue;
|
||||
@@ -364,8 +364,8 @@ void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms& parms, int selAre
|
||||
|
||||
zeus::CVector3f pos = modelView * (obj.GetTransform().origin +
|
||||
CMapArea::GetAreaPostTranslate(parms.GetWorld(), thisArea));
|
||||
sortInfos.emplace_back(pos.y, thisArea, doorType ? CMapObjectSortInfo::EObjectCode::Door :
|
||||
CMapObjectSortInfo::EObjectCode::Object,
|
||||
sortInfos.emplace_back(pos.y(), thisArea, doorType ? CMapObjectSortInfo::EObjectCode::Door :
|
||||
CMapObjectSortInfo::EObjectCode::Object,
|
||||
i, zeus::CColor{1.f, 0.f, 1.f, 1.f}, zeus::CColor{1.f, 0.f, 1.f, 1.f});
|
||||
}
|
||||
}
|
||||
@@ -476,8 +476,8 @@ static Circle2 ExactCircle3(const zeus::CVector2f* a, const zeus::CVector2f* b,
|
||||
zeus::CVector2f magVec(d1.magSquared() * 0.5f, d2.magSquared() * 0.5f);
|
||||
if (std::fabs(cross) > 0.01f)
|
||||
{
|
||||
zeus::CVector2f tmp((d2.y * magVec.x - d1.y * magVec.y) / cross,
|
||||
(d1.x * magVec.y - d2.x * magVec.x) / cross);
|
||||
zeus::CVector2f tmp((d2.y() * magVec.x() - d1.y() * magVec.y()) / cross,
|
||||
(d1.x() * magVec.y() - d2.x() * magVec.x()) / cross);
|
||||
ret.x0_point = *a + tmp;
|
||||
ret.x8_radiusSq = tmp.magSquared();
|
||||
}
|
||||
@@ -760,10 +760,10 @@ void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld
|
||||
zeus::CAABox aabb = mapa->GetBoundingBox().getTransformedAABox(mapa->GetAreaPostTransform(wld, i));
|
||||
for (int j=0 ; j<8 ; ++j)
|
||||
{
|
||||
zeus::CVector3f point = aabb.getPoint(j);
|
||||
coords.emplace_back(point.x, point.y);
|
||||
zMin = std::min(point.z, zMin);
|
||||
zMax = std::max(point.z, zMax);
|
||||
const zeus::CVector3f point = aabb.getPoint(j);
|
||||
coords.push_back(point.toVec2f());
|
||||
zMin = std::min(point.z(), zMin);
|
||||
zMax = std::max(point.z(), zMax);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -772,35 +772,35 @@ void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld
|
||||
Circle circle = MinCircle(coords);
|
||||
const_cast<CMapWorld*>(this)->x3c_worldSphereRadius = circle.x8_radius;
|
||||
const_cast<CMapWorld*>(this)->x30_worldSpherePoint =
|
||||
zeus::CVector3f(circle.x0_point.x, circle.x0_point.y, (zMin + zMax) * 0.5f);
|
||||
zeus::CVector3f(circle.x0_point.x(), circle.x0_point.y(), (zMin + zMax) * 0.5f);
|
||||
const_cast<CMapWorld*>(this)->x40_worldSphereHalfDepth = (zMax - zMin) * 0.5f;
|
||||
}
|
||||
|
||||
zeus::CVector3f CMapWorld::ConstrainToWorldVolume(const zeus::CVector3f& point, const zeus::CVector3f& lookVec) const
|
||||
{
|
||||
zeus::CVector3f ret = point;
|
||||
if (std::fabs(lookVec.z) > FLT_EPSILON)
|
||||
if (std::fabs(lookVec.z()) > FLT_EPSILON)
|
||||
{
|
||||
float f2 = point.z - (x40_worldSphereHalfDepth + x30_worldSpherePoint.z);
|
||||
float f1 = point.z - (x30_worldSpherePoint.z - x40_worldSphereHalfDepth);
|
||||
float f2 = point.z() - (x40_worldSphereHalfDepth + x30_worldSpherePoint.z());
|
||||
float f1 = point.z() - (x30_worldSpherePoint.z() - x40_worldSphereHalfDepth);
|
||||
if (f2 > 0.f)
|
||||
ret = point + lookVec * (-f2 / lookVec.z);
|
||||
ret = point + lookVec * (-f2 / lookVec.z());
|
||||
else if (f1 < 0.f)
|
||||
ret = point + lookVec * (-f1 / lookVec.z);
|
||||
ret = point + lookVec * (-f1 / lookVec.z());
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.z = zeus::clamp(x30_worldSpherePoint.z - x40_worldSphereHalfDepth, ret.z,
|
||||
x40_worldSphereHalfDepth + x30_worldSpherePoint.z);
|
||||
ret.z() = zeus::clamp(x30_worldSpherePoint.z() - x40_worldSphereHalfDepth, float(ret.z()),
|
||||
x40_worldSphereHalfDepth + x30_worldSpherePoint.z());
|
||||
}
|
||||
|
||||
zeus::CVector2f tmp(x30_worldSpherePoint.x, x30_worldSpherePoint.y);
|
||||
zeus::CVector2f vec2 = zeus::CVector2f(point.x, point.y) - tmp;
|
||||
zeus::CVector2f tmp = x30_worldSpherePoint.toVec2f();
|
||||
zeus::CVector2f vec2 = point.toVec2f() - tmp;
|
||||
if (vec2.magnitude() > x3c_worldSphereRadius)
|
||||
{
|
||||
tmp += vec2.normalized() * x3c_worldSphereRadius;
|
||||
ret.x = tmp.x;
|
||||
ret.y = tmp.y;
|
||||
ret.x() = float(tmp.x());
|
||||
ret.y() = float(tmp.y());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -31,8 +31,8 @@ CMappableObject::CMappableObject(const void* buf)
|
||||
|
||||
zeus::CTransform CMappableObject::AdjustTransformForType()
|
||||
{
|
||||
const float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x;
|
||||
const float doorCenterZ = g_tweakAutoMapper->GetDoorCenter().z;
|
||||
const float doorCenterX = g_tweakAutoMapper->GetDoorCenter().x();
|
||||
const float doorCenterZ = g_tweakAutoMapper->GetDoorCenter().z();
|
||||
if (x0_type == EMappableObjectType::BigDoor1)
|
||||
{
|
||||
zeus::CTransform orientation;
|
||||
@@ -127,11 +127,11 @@ CMappableObject::GetDoorColors(int curAreaId, const CMapWorldInfo& mwInfo, float
|
||||
color = zeus::CColor::skClear;
|
||||
}
|
||||
|
||||
color.a *= alpha;
|
||||
return {color, zeus::CColor(std::min(1.4f * color.r, 1.f),
|
||||
std::min(1.4f * color.g, 1.f),
|
||||
std::min(1.4f * color.b, 1.f),
|
||||
std::min(1.4f * color.a, 1.f))};
|
||||
color.a() *= alpha;
|
||||
return {color, zeus::CColor(std::min(1.4f * color.r(), 1.f),
|
||||
std::min(1.4f * color.g(), 1.f),
|
||||
std::min(1.4f * color.b(), 1.f),
|
||||
std::min(1.4f * color.a(), 1.f))};
|
||||
}
|
||||
|
||||
void CMappableObject::PostConstruct(const void *)
|
||||
@@ -200,7 +200,7 @@ void CMappableObject::Draw(int curArea, const CMapWorldInfo& mwInfo,
|
||||
break;
|
||||
}
|
||||
|
||||
iconColor.a *= alpha;
|
||||
iconColor.a() *= alpha;
|
||||
|
||||
TLockedToken<CTexture> tex = g_SimplePool->GetObj(SObjectTag{FOURCC('TXTR'), iconRes});
|
||||
if (!m_texQuadFilter || m_texQuadFilter->GetTex().GetObj() != tex.GetObj())
|
||||
@@ -243,15 +243,15 @@ zeus::CVector3f CMappableObject::BuildSurfaceCenterPoint(int surfIdx) const
|
||||
case 0:
|
||||
return x10_transform * zeus::CVector3f::skZero;
|
||||
case 1:
|
||||
return x10_transform * zeus::CVector3f{0.f, 0.f, 2.f * doorCenter.x};
|
||||
return x10_transform * zeus::CVector3f{0.f, 0.f, 2.f * doorCenter.x()};
|
||||
case 2:
|
||||
return x10_transform * zeus::CVector3f{0.f, -doorCenter.y, 0.f};
|
||||
return x10_transform * zeus::CVector3f{0.f, -doorCenter.y(), 0.f};
|
||||
case 3:
|
||||
return x10_transform * zeus::CVector3f{0.f, doorCenter.y, 0.f};
|
||||
return x10_transform * zeus::CVector3f{0.f, doorCenter.y(), 0.f};
|
||||
case 4:
|
||||
return x10_transform * zeus::CVector3f{-doorCenter.x, 0.f, 0.f};
|
||||
return x10_transform * zeus::CVector3f{-doorCenter.x(), 0.f, 0.f};
|
||||
case 5:
|
||||
return x10_transform * zeus::CVector3f{doorCenter.x, 0.f, 0.f};
|
||||
return x10_transform * zeus::CVector3f{doorCenter.x(), 0.f, 0.f};
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -284,16 +284,17 @@ boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorIbo;
|
||||
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)
|
||||
{
|
||||
const zeus::CVector3f& center = tweaks.GetDoorCenter();
|
||||
zeus::simd_floats centerF(center.mSimd);
|
||||
zeus::CVector3f* doorVerts = const_cast<zeus::CVector3f*>(&CMappableObject::skDoorVerts[0]);
|
||||
/* Wrap door verts around -Z to build surface */
|
||||
doorVerts[0].assign( -center.z, -center.y, 0.f);
|
||||
doorVerts[1].assign( -center.z, -center.y, 2.f * center.x);
|
||||
doorVerts[2].assign( -center.z, center.y, 0.f);
|
||||
doorVerts[3].assign( -center.z, center.y, 2.f * center.x);
|
||||
doorVerts[4].assign(.2f * -center.z, -center.y, 0.f);
|
||||
doorVerts[5].assign(.2f * -center.z, -center.y, 2.f * center.x);
|
||||
doorVerts[6].assign(.2f * -center.z, center.y, 0.f);
|
||||
doorVerts[7].assign(.2f * -center.z, center.y, 2.f * center.x);
|
||||
doorVerts[0].assign( -centerF[2], -centerF[1], 0.f);
|
||||
doorVerts[1].assign( -centerF[2], -centerF[1], 2.f * centerF[0]);
|
||||
doorVerts[2].assign( -centerF[2], centerF[1], 0.f);
|
||||
doorVerts[3].assign( -centerF[2], centerF[1], 2.f * centerF[0]);
|
||||
doorVerts[4].assign(.2f * -centerF[2], -centerF[1], 0.f);
|
||||
doorVerts[5].assign(.2f * -centerF[2], -centerF[1], 2.f * centerF[0]);
|
||||
doorVerts[6].assign(.2f * -centerF[2], centerF[1], 0.f);
|
||||
doorVerts[7].assign(.2f * -centerF[2], centerF[1], 2.f * centerF[0]);
|
||||
|
||||
CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user