mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'master' of ssh://gitlab.axiodl.com:6431/AxioDL/urde
This commit is contained in:
commit
2a8edf9da8
|
@ -13,17 +13,19 @@ find_package(Sanitizers)
|
|||
option(URDE_SSE2 "Enable SSE2 flags." Off)
|
||||
option(URDE_SSE3 "Enable SSE3 flags." On)
|
||||
option(URDE_SSE41 "Enable SSE4.1 flags." Off)
|
||||
option(URDE_AVX "Enable AVX flags." Off)
|
||||
option(URDE_AVX2 "Enable AVX2 flags." Off)
|
||||
|
||||
if(MSVC)
|
||||
if(URDE_SSE41)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
|
||||
elseif(URDE_SSE3)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
|
||||
elseif(URDE_SSE2)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2")
|
||||
if(URDE_AVX2)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 -D__SSE4_1__=1")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2 -D__SSE4_1__=1")
|
||||
elseif(URDE_AVX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -D__SSE4_1__=1")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:SSE2 -D__SSE4_1__=1")
|
||||
elseif(URDE_SSE41)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__SSE4_1__=1")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__SSE4_1__=1")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_GENERATOR} MATCHES "Visual Studio*")
|
||||
|
@ -52,7 +54,13 @@ if(MSVC)
|
|||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
|
||||
|
||||
else()
|
||||
if(URDE_SSE41)
|
||||
if(URDE_AVX2)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
|
||||
elseif(URDE_AVX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
|
||||
elseif(URDE_SSE41)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
|
||||
elseif(URDE_SSE3)
|
||||
|
|
|
@ -131,56 +131,79 @@ static void PopulateAreaFields(DEAFBABE& db,
|
|||
db.memSize = 0;
|
||||
}
|
||||
|
||||
class MaterialPool
|
||||
{
|
||||
std::unordered_map<u64, int> m_materials;
|
||||
public:
|
||||
template <class M, class V>
|
||||
int AddOrLookup(const M& mat, V& vec)
|
||||
{
|
||||
auto search = m_materials.find(mat.material);
|
||||
if (search != m_materials.end())
|
||||
return search->second;
|
||||
auto idx = int(vec.size());
|
||||
vec.push_back(mat);
|
||||
m_materials[mat.material] = idx;
|
||||
return idx;
|
||||
}
|
||||
};
|
||||
|
||||
template<class DEAFBABE>
|
||||
void DeafBabeBuildFromBlender(DEAFBABE& db, const hecl::BlenderConnection::DataStream::ColMesh& colMesh)
|
||||
{
|
||||
db.materials.reserve(colMesh.materials.size() * 2);
|
||||
for (const hecl::BlenderConnection::DataStream::ColMesh::Material& mat : colMesh.materials)
|
||||
using BlendMat = hecl::BlenderConnection::DataStream::ColMesh::Material;
|
||||
|
||||
auto MakeMat = [](const BlendMat& mat, bool flipFace) -> typename DEAFBABE::Material
|
||||
{
|
||||
db.materials.emplace_back();
|
||||
db.materials.back().setUnknown(mat.unknown);
|
||||
db.materials.back().setSurfaceStone(mat.surfaceStone);
|
||||
db.materials.back().setSurfaceMetal(mat.surfaceMetal);
|
||||
db.materials.back().setSurfaceGrass(mat.surfaceGrass);
|
||||
db.materials.back().setSurfaceIce(mat.surfaceIce);
|
||||
db.materials.back().setPillar(mat.pillar);
|
||||
db.materials.back().setSurfaceMetalGrating(mat.surfaceMetalGrating);
|
||||
db.materials.back().setSurfacePhazon(mat.surfacePhazon);
|
||||
db.materials.back().setSurfaceDirt(mat.surfaceDirt);
|
||||
db.materials.back().setSurfaceLava(mat.surfaceLava);
|
||||
db.materials.back().setSurfaceSPMetal(mat.surfaceSPMetal);
|
||||
db.materials.back().setSurfaceStoneRock(mat.surfaceStoneRock);
|
||||
db.materials.back().setSurfaceSnow(mat.surfaceSnow);
|
||||
db.materials.back().setSurfaceMudSlow(mat.surfaceMudSlow);
|
||||
db.materials.back().setSurfaceFabric(mat.surfaceFabric);
|
||||
db.materials.back().setHalfPipe(mat.halfPipe);
|
||||
db.materials.back().setSurfaceMud(mat.surfaceMud);
|
||||
db.materials.back().setSurfaceGlass(mat.surfaceGlass);
|
||||
db.materials.back().setUnused3(mat.unused3);
|
||||
db.materials.back().setUnused4(mat.unused4);
|
||||
db.materials.back().setSurfaceShield(mat.surfaceShield);
|
||||
db.materials.back().setSurfaceSand(mat.surfaceSand);
|
||||
db.materials.back().setSurfaceMothOrSeedOrganics(mat.surfaceMothOrSeedOrganics);
|
||||
db.materials.back().setSurfaceWeb(mat.surfaceWeb);
|
||||
db.materials.back().setProjectilePassthrough(mat.projPassthrough);
|
||||
db.materials.back().setSolid(mat.solid);
|
||||
db.materials.back().setU20(mat.u20);
|
||||
db.materials.back().setCameraPassthrough(mat.camPassthrough);
|
||||
db.materials.back().setSurfaceWood(mat.surfaceWood);
|
||||
db.materials.back().setSurfaceOrganic(mat.surfaceOrganic);
|
||||
db.materials.back().setU24(mat.u24);
|
||||
db.materials.back().setSurfaceRubber(mat.surfaceRubber);
|
||||
db.materials.back().setSeeThrough(mat.seeThrough);
|
||||
db.materials.back().setScanPassthrough(mat.scanPassthrough);
|
||||
db.materials.back().setAiPassthrough(mat.aiPassthrough);
|
||||
db.materials.back().setCeiling(mat.ceiling);
|
||||
db.materials.back().setWall(mat.wall);
|
||||
db.materials.back().setFloor(mat.floor);
|
||||
db.materials.back().setAiBlock(mat.aiBlock);
|
||||
db.materials.back().setJumpNotAllowed(mat.jumpNotAllowed);
|
||||
db.materials.back().setSpiderBall(mat.spiderBall);
|
||||
db.materials.back().setScrewAttackWallJump(mat.screwAttackWallJump);
|
||||
}
|
||||
typename DEAFBABE::Material dbMat = {};
|
||||
dbMat.setUnknown(mat.unknown);
|
||||
dbMat.setSurfaceStone(mat.surfaceStone);
|
||||
dbMat.setSurfaceMetal(mat.surfaceMetal);
|
||||
dbMat.setSurfaceGrass(mat.surfaceGrass);
|
||||
dbMat.setSurfaceIce(mat.surfaceIce);
|
||||
dbMat.setPillar(mat.pillar);
|
||||
dbMat.setSurfaceMetalGrating(mat.surfaceMetalGrating);
|
||||
dbMat.setSurfacePhazon(mat.surfacePhazon);
|
||||
dbMat.setSurfaceDirt(mat.surfaceDirt);
|
||||
dbMat.setSurfaceLava(mat.surfaceLava);
|
||||
dbMat.setSurfaceSPMetal(mat.surfaceSPMetal);
|
||||
dbMat.setSurfaceStoneRock(mat.surfaceStoneRock);
|
||||
dbMat.setSurfaceSnow(mat.surfaceSnow);
|
||||
dbMat.setSurfaceMudSlow(mat.surfaceMudSlow);
|
||||
dbMat.setSurfaceFabric(mat.surfaceFabric);
|
||||
dbMat.setHalfPipe(mat.halfPipe);
|
||||
dbMat.setSurfaceMud(mat.surfaceMud);
|
||||
dbMat.setSurfaceGlass(mat.surfaceGlass);
|
||||
dbMat.setUnused3(mat.unused3);
|
||||
dbMat.setUnused4(mat.unused4);
|
||||
dbMat.setSurfaceShield(mat.surfaceShield);
|
||||
dbMat.setSurfaceSand(mat.surfaceSand);
|
||||
dbMat.setSurfaceMothOrSeedOrganics(mat.surfaceMothOrSeedOrganics);
|
||||
dbMat.setSurfaceWeb(mat.surfaceWeb);
|
||||
dbMat.setProjectilePassthrough(mat.projPassthrough);
|
||||
dbMat.setSolid(mat.solid);
|
||||
dbMat.setU20(mat.u20);
|
||||
dbMat.setCameraPassthrough(mat.camPassthrough);
|
||||
dbMat.setSurfaceWood(mat.surfaceWood);
|
||||
dbMat.setSurfaceOrganic(mat.surfaceOrganic);
|
||||
dbMat.setU24(mat.u24);
|
||||
dbMat.setSurfaceRubber(mat.surfaceRubber);
|
||||
dbMat.setSeeThrough(mat.seeThrough);
|
||||
dbMat.setScanPassthrough(mat.scanPassthrough);
|
||||
dbMat.setAiPassthrough(mat.aiPassthrough);
|
||||
dbMat.setCeiling(mat.ceiling);
|
||||
dbMat.setWall(mat.wall);
|
||||
dbMat.setFloor(mat.floor);
|
||||
dbMat.setAiBlock(mat.aiBlock);
|
||||
dbMat.setJumpNotAllowed(mat.jumpNotAllowed);
|
||||
dbMat.setSpiderBall(mat.spiderBall);
|
||||
dbMat.setScrewAttackWallJump(mat.screwAttackWallJump);
|
||||
dbMat.setFlipFace(flipFace);
|
||||
return dbMat;
|
||||
};
|
||||
|
||||
MaterialPool matPool;
|
||||
db.materials.reserve(colMesh.materials.size() * 2);
|
||||
|
||||
zeus::CAABox fullAABB;
|
||||
|
||||
|
@ -209,16 +232,8 @@ void DeafBabeBuildFromBlender(DEAFBABE& db, const hecl::BlenderConnection::DataS
|
|||
db.triangleEdgeConnections.reserve(colMesh.trianges.size());
|
||||
for (const auto& tri : colMesh.trianges)
|
||||
{
|
||||
if (tri.flip)
|
||||
{
|
||||
db.triMats.push_back(db.materials.size());
|
||||
db.materials.push_back(db.materials[tri.matIdx]);
|
||||
db.materials.back().setFlipFace(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
db.triMats.push_back(tri.matIdx);
|
||||
}
|
||||
int triMatIdx = matPool.AddOrLookup(MakeMat(colMesh.materials[tri.matIdx], tri.flip), db.materials);
|
||||
db.triMats.push_back(triMatIdx);
|
||||
|
||||
db.triangleEdgeConnections.emplace_back();
|
||||
db.triangleEdgeConnections.back().edges[0] = tri.edges[0];
|
||||
|
@ -227,9 +242,9 @@ void DeafBabeBuildFromBlender(DEAFBABE& db, const hecl::BlenderConnection::DataS
|
|||
|
||||
for (int e=0 ; e<3 ; ++e)
|
||||
{
|
||||
db.edgeMats[tri.edges[e]] = tri.matIdx;
|
||||
db.edgeMats[tri.edges[e]] = triMatIdx;
|
||||
for (int v=0 ; v<2 ; ++v)
|
||||
db.vertMats[colMesh.edges[e].verts[v]] = tri.matIdx;
|
||||
db.vertMats[colMesh.edges[e].verts[v]] = triMatIdx;
|
||||
}
|
||||
}
|
||||
db.triMatsCount = colMesh.trianges.size();
|
||||
|
|
|
@ -86,7 +86,6 @@ void CFirstPersonCamera::CalculateGunFollowOrientationAndTransform(zeus::CTransf
|
|||
{
|
||||
zeus::CVector3f gunFrontVec = x190_gunFollowXf.frontVector();
|
||||
gunFrontVec.z = 0.f;
|
||||
|
||||
if (gunFrontVec.canBeNormalized())
|
||||
gunFrontVec.normalize();
|
||||
|
||||
|
@ -95,16 +94,15 @@ void CFirstPersonCamera::CalculateGunFollowOrientationAndTransform(zeus::CTransf
|
|||
if (rVecNoZ.canBeNormalized())
|
||||
rVecNoZ.normalize();
|
||||
|
||||
gunXf = zeus::CQuaternion::lookAt(gunFrontVec, rVecNoZ, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
|
||||
gunXf = zeus::CQuaternion::lookAt(gunFrontVec, rVecNoZ, 2.f * M_PIF).toTransform() *
|
||||
x190_gunFollowXf.getRotation();
|
||||
|
||||
zeus::CVector3f newgunFront = gunXf.frontVector();
|
||||
|
||||
if (newgunFront.canBeNormalized())
|
||||
newgunFront.normalize();
|
||||
|
||||
float angle = newgunFront.dot(rVec);
|
||||
angle = std::min(angle, 1.f);
|
||||
angle = zeus::clamp(-1.f, angle, 1.f);
|
||||
gunQ = zeus::CQuaternion::lookAt(newgunFront, rVec, zeus::clamp(0.f, std::acos(angle) / dt, 1.f) * dt);
|
||||
}
|
||||
|
||||
|
@ -136,7 +134,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
|
|||
vec.normalize();
|
||||
}
|
||||
|
||||
rVec = zeus::CQuaternion::lookAt({0.f, 1.f, 0.f}, rVec, zeus::CRelAngle::FromDegrees(360.f)).transform(vec);
|
||||
rVec = zeus::CQuaternion::lookAt({0.f, 1.f, 0.f}, rVec, 2.f * M_PIF).transform(vec);
|
||||
}
|
||||
|
||||
zeus::CVector3f eyePos = player->GetEyePosition();
|
||||
|
@ -198,11 +196,11 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
|
|||
float angle = zeus::clamp(0.f, (player->x29c_fallCameraTimer - g_tweakPlayer->GetFallCameraPitchDownStart()) /
|
||||
g_tweakPlayer->GetFallCameraPitchDownFull(), 1.f) *
|
||||
g_tweakPlayer->GetFallCameraPitchDownAngle();
|
||||
//rVec.x = 0.f;
|
||||
//rVec.y = std::cos(angle);
|
||||
//rVec.z = -std::sin(angle);
|
||||
rVec.x = 0.f;
|
||||
rVec.y = std::cos(angle);
|
||||
rVec.z = -std::sin(angle);
|
||||
|
||||
//rVec = playerXf.rotate(rVec);
|
||||
rVec = playerXf.rotate(rVec);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -253,7 +251,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
|
|||
angle = zeus::clamp(-1.f, angle, 1.f);
|
||||
float clampedAngle = zeus::clamp(0.f, std::acos(angle) / scaledDt, 1.f);
|
||||
if (angle > 0.999f || x18c_lockCamera || player->x374_orbitLockEstablished)
|
||||
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVec, zeus::CRelAngle::FromDegrees(360.f));
|
||||
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVec, 2.f * M_PIF);
|
||||
else
|
||||
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVec, scaledDt * clampedAngle);
|
||||
|
||||
|
@ -271,7 +269,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
|
|||
rVecCpy.normalize();
|
||||
|
||||
gunXf =
|
||||
zeus::CQuaternion::lookAt(gunFrontVec, rVecCpy, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
|
||||
zeus::CQuaternion::lookAt(gunFrontVec, rVecCpy, 2.f * M_PIF).toTransform() *
|
||||
x190_gunFollowXf.getRotation();
|
||||
|
||||
gunFrontVec = gunXf.frontVector();
|
||||
|
@ -283,7 +281,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
|
|||
|
||||
//angle = zeus::clamp(-1.f, angle, 1.f);
|
||||
//angle = zeus::clamp(0.f, std::acos(angle) / sdt, 1.f);
|
||||
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVecCpy, zeus::CRelAngle::FromDegrees(360.f));
|
||||
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVecCpy, 2.f * M_PIF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -301,7 +299,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
|
|||
if (rVecCpy.canBeNormalized())
|
||||
rVecCpy.normalize();
|
||||
|
||||
gunXf = zeus::CQuaternion::lookAt(gunFront, rVecCpy, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
|
||||
gunXf = zeus::CQuaternion::lookAt(gunFront, rVecCpy, 2.f * M_PIF).toTransform() *
|
||||
x190_gunFollowXf.getRotation();
|
||||
gunFront = gunXf.frontVector();
|
||||
if (gunFront.canBeNormalized())
|
||||
|
@ -328,8 +326,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
|
|||
}
|
||||
|
||||
x190_gunFollowXf = qGun.toTransform() * gunXf;
|
||||
//SetTransform(x190_gunFollowXf * bobXf.getRotation());
|
||||
SetTransform(playerXf);
|
||||
SetTransform(x190_gunFollowXf * bobXf.getRotation());
|
||||
x190_gunFollowXf.origin = eyePos;
|
||||
CActor::SetTranslation(eyePos + player->GetTransform().rotate(bobXf.origin));
|
||||
x190_gunFollowXf.orthonormalize();
|
||||
|
|
|
@ -55,6 +55,12 @@ public:
|
|||
m_leftDiv(leftDiv),
|
||||
m_rightDiv(rightDiv) {}
|
||||
|
||||
~CInputGenerator()
|
||||
{
|
||||
if (smashAdapter)
|
||||
smashAdapter->setCallback(nullptr);
|
||||
}
|
||||
|
||||
/* Keyboard and mouse events are delivered on the main game
|
||||
* thread as part of the app's main event loop. The OS is responsible
|
||||
* for buffering events in its own way, then boo flushes the buffer
|
||||
|
|
2
amuse
2
amuse
|
@ -1 +1 @@
|
|||
Subproject commit 91b88c0568334c49a22c8f7bcc94f35e495f9a00
|
||||
Subproject commit 3eba4cc1ac7cf08c23107302807e6d1adf9087db
|
Loading…
Reference in New Issue