Merge remote-tracking branch 'origin/main' into utf8

# Conflicts:
#	DataSpec/DNAMP1/FRME.cpp
#	DataSpec/DNAMP1/MLVL.cpp
#	Runtime/CMain.cpp
#	hecl/lib/Blender/Connection.cpp
This commit is contained in:
Luke Street 2021-10-25 19:03:01 -04:00
commit 32e115f4aa
28 changed files with 481 additions and 238 deletions

View File

@ -460,7 +460,8 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
}
zeus::simd_floats colorF(w.header.color.simd);
os.format(FMT_STRING("frme_obj = bpy.data.objects.new(name='{}', object_data=binding)\n"
os.format(FMT_STRING(
"frme_obj = bpy.data.objects.new(name='{}', object_data=binding)\n"
"frme_obj.pass_index = {}\n"
"parentName = '{}'\n"
"frme_obj.retro_widget_type = 'RETRO_{}'\n"
@ -469,18 +470,21 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
"frme_obj.retro_widget_default_active = {}\n"
"frme_obj.retro_widget_cull_faces = {}\n"
"frme_obj.retro_widget_color = ({},{},{},{})\n"
"frme_obj.retro_widget_model_draw_flags = "
"bpy.types.Object.retro_widget_model_draw_flags[1]['items'][{}][0]\n"
"widget_model_draw_flags = {}\n"
"if bpy.app.version >= (2, 93, 0):\n"
" frme_obj.retro_widget_model_draw_flags = bpy.types.Object.retro_widget_model_draw_flags.keywords['items'][widget_model_draw_flags][0]\n"
"else:\n"
" frme_obj.retro_widget_model_draw_flags = bpy.types.Object.retro_widget_model_draw_flags[1]['items'][widget_model_draw_flags][0]\n"
"frme_obj.retro_widget_is_worker = {}\n"
"frme_obj.retro_widget_worker_id = {}\n"
"if parentName not in bpy.data.objects:\n"
" frme_obj.retro_widget_parent = parentName\n"
"else:\n"
" frme_obj.parent = bpy.data.objects[parentName]\n"),
w.header.name, pIdx++, w.header.parent, w.type, w.header.useAnimController ? "True" : "False",
w.header.defaultVisible ? "True" : "False", w.header.defaultActive ? "True" : "False",
w.header.cullFaces ? "True" : "False", colorF[0], colorF[1], colorF[2], colorF[3],
w.header.modelDrawFlags, w.isWorker ? "True" : "False", w.workerId);
w.header.name, pIdx++, w.header.parent, w.type,
w.header.useAnimController ? "True" : "False", w.header.defaultVisible ? "True" : "False",
w.header.defaultActive ? "True" : "False", w.header.cullFaces ? "True" : "False", colorF[0], colorF[1],
colorF[2], colorF[3], w.header.modelDrawFlags, w.isWorker ? "True" : "False", w.workerId);
if (w.type == SBIG('MODL')) {
using MODLInfo = FRME::Widget::MODLInfo;
@ -521,7 +525,8 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
zeus::simd_floats fillF(info->fillColor.simd);
zeus::simd_floats outlineF(info->outlineColor.simd);
zeus::simd_floats extentF(info->blockExtent.simd);
os.format(FMT_STRING("frme_obj.retro_pane_dimensions = ({},{})\n"
os.format(FMT_STRING(
"frme_obj.retro_pane_dimensions = ({},{})\n"
"frme_obj.retro_pane_scale_center = ({},{},{})\n"
"frme_obj.retro_textpane_font_path = '{}'\n"
"frme_obj.retro_textpane_word_wrap = {}\n"
@ -531,10 +536,14 @@ bool FRME::Extract(const SpecBase& dataSpec, PAKEntryReadStream& rs, const hecl:
"frme_obj.retro_textpane_block_extent = ({},{})\n"
"frme_obj.retro_textpane_jp_font_path = '{}'\n"
"frme_obj.retro_textpane_jp_font_scale = ({},{})\n"
"frme_obj.retro_textpane_hjustification = "
"bpy.types.Object.retro_textpane_hjustification[1]['items'][{}][0]\n"
"frme_obj.retro_textpane_vjustification = "
"bpy.types.Object.retro_textpane_vjustification[1]['items'][{}][0]\n"),
"textpane_hjustification = {}\n"
"textpane_vjustification = {}\n"
"if bpy.app.version >= (2, 93, 0):\n"
" frme_obj.retro_textpane_hjustification = bpy.types.Object.retro_textpane_hjustification.keywords['items'][textpane_hjustification][0]\n"
" frme_obj.retro_textpane_vjustification = bpy.types.Object.retro_textpane_vjustification.keywords['items'][textpane_vjustification][0]\n"
"else:\n"
" frme_obj.retro_textpane_hjustification = bpy.types.Object.retro_textpane_hjustification[1]['items'][textpane_hjustification][0]\n"
" frme_obj.retro_textpane_vjustification = bpy.types.Object.retro_textpane_vjustification[1]['items'][textpane_vjustification][0]\n"),
info->xDim, info->zDim, scaleF[0], scaleF[1], scaleF[2], fontPath.getRelativePath(),
info->wordWrap ? "True" : "False", info->horizontal ? "True" : "False", fillF[0], fillF[1], fillF[2],
fillF[3], outlineF[0], outlineF[1], outlineF[2], outlineF[3], extentF[0], extentF[1],

View File

@ -157,8 +157,8 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
bool areaInit = false;
size_t layerIdx = 0;
LayerResources layerResources;
for (const hecl::DirectoryEnumerator::Entry& e :
hecl::DirectoryEnumerator(area.path.getAbsolutePath(), hecl::DirectoryEnumerator::Mode::DirsSorted)) {
const hecl::DirectoryEnumerator enumerator(area.path.getAbsolutePath(), hecl::DirectoryEnumerator::Mode::DirsSorted);
for (const hecl::DirectoryEnumerator::Entry& e : enumerator) {
std::string layerName;
char* endCh = nullptr;
hecl::StrToUl(e.m_name.c_str(), &endCh, 10);

View File

@ -654,6 +654,7 @@ bool MREA::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
}
}
}
visiGood = true;
#if !WINDOWS_STORE
if (!visiGood) {

View File

@ -74,13 +74,22 @@ NFS files dumped from Metroid Prime Trilogy on Wii U VC can be used directly wit
```
build-essential curl git ninja-build clang lld zlib1g-dev libcurl4-openssl-dev \
libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev libpulse-dev \
libudev-dev libpng-dev libncurses5-dev cmake libx11-xcb-dev python3 python-is-python3 qt5-default
libudev-dev libpng-dev libncurses5-dev cmake libx11-xcb-dev python3 python-is-python3 \
qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libclang-dev
```
* Arch Linux packages
```
base-devel cmake ninja llvm vulkan-headers python3 qt6 clang lld alsa-lib libpulse libxrandr
```
* Fedora packages
```
cmake vulkan-headers ninja-build clang-devel llvm-devel libpng-devel qt6-qtbase-devel
qt6-linguist qt6-qttools-devel qt6-qtscxml-devel qt6-qtsvg-devel qt6-qt5compat-devel
```
* It's also important that you install the developer tools and libraries
```
sudo dnf groupinstall "Development Tools" "Development Libraries"
```
### Prep Directions
```sh

View File

@ -13,6 +13,9 @@
#include "../version.h"
//#include <fenv.h>
//#pragma STDC FENV_ACCESS ON
/* Static reference to dataspec additions
* (used by MSVC to definitively link DataSpecs) */
#include "DataSpecRegistry.hpp"
@ -461,7 +464,7 @@ public:
using delta_duration = std::chrono::duration<float, std::ratio<1>>;
realDt = std::chrono::duration_cast<delta_duration>(now - m_prevFrameTime).count();
if (m_cvarCommons.m_variableDt->toBoolean()) {
dt = std::max(realDt, 1 / 30.f);
dt = std::min(realDt, 1 / 30.f);
}
}
m_prevFrameTime = now;
@ -576,6 +579,10 @@ static bool IsClientLoggingEnabled(int argc, char** argv) {
#if !WINDOWS_STORE
int main(int argc, char** argv) {
//TODO: This seems to fix a lot of weird issues with rounding
// but breaks animations, need to research why this is the case
// for now it's disabled
//fesetround(FE_TOWARDZERO);
if (argc > 1 && !hecl::StrCmp(argv[1], "--dlpackage")) {
fmt::print(FMT_STRING("{}\n"), METAFORCE_DLPACKAGE);
return 100;

View File

@ -216,10 +216,13 @@ CStateManager::CStateManager(const std::weak_ptr<CScriptMailbox>& mailbox, const
x8f0_shadowTex = g_SimplePool->GetObj("DefaultShadow");
g_StateManager = this;
if (sm_logScripting == nullptr) {
sm_logScripting = hecl::CVarManager::instance()->findOrMakeCVar(
"stateManager.logScripting"sv, "Prints object communication to the console", false,
hecl::CVar::EFlags::ReadOnly | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::Game);
}
m_logScriptingReference.emplace(&m_logScripting, sm_logScripting);
}
CStateManager::~CStateManager() {
x88c_rumbleManager->HardStopAll();
@ -1326,7 +1329,7 @@ void CStateManager::SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMes
return;
}
if (sm_logScripting != nullptr && sm_logScripting->toBoolean()) {
if (m_logScripting) {
LogModule.report(logvisor::Info, FMT_STRING("Sending '{}' to '{}' id= {}"), ScriptObjectMessageToStr(msg),
dest->GetName(), dest->GetUniqueId());
}
@ -1345,7 +1348,7 @@ void CStateManager::SendScriptMsgAlways(TUniqueId dest, TUniqueId src, EScriptOb
return;
}
if (sm_logScripting != nullptr && sm_logScripting->toBoolean()) {
if (m_logScripting) {
LogModule.report(logvisor::Info, FMT_STRING("Sending '{}' to '{}' id= {}"), ScriptObjectMessageToStr(msg),
dst->GetName(), dst->GetUniqueId());
}
@ -1415,7 +1418,7 @@ void CStateManager::FreeScriptObject(TUniqueId id) {
act->SetUseInSortedLists(false);
}
if (sm_logScripting && sm_logScripting->toBoolean()) {
if (m_logScripting) {
LogModule.report(logvisor::Info, FMT_STRING("Removed '{}'"), ent->GetName());
}
}
@ -2771,7 +2774,7 @@ void CStateManager::AddObject(CEntity& ent) {
}
}
if (sm_logScripting != nullptr && sm_logScripting->toBoolean()) {
if (m_logScripting) {
LogModule.report(logvisor::Info, FMT_STRING("Added '{}'"), ent.GetName());
}
}

View File

@ -216,6 +216,8 @@ private:
bool m_warping = false;
std::map<TEditorId, std::set<SConnection>> m_incomingConnections;
bool m_logScripting = false;
std::optional<hecl::CVarValueReference<bool>> m_logScriptingReference;
void UpdateThermalVisor();
static void RendererDrawCallback(void*, void*, int);

View File

@ -64,7 +64,7 @@ CRayCastResult CCollidableOBBTreeGroup::CastRayInternal(const CInternalRayCastSt
CCollidableOBBTree obbTree(tree.get(), GetMaterial());
float tMin = 0.f;
float tMax = 0.f;
if (CollisionUtil::RayAABoxIntersection(xfRay, *aabbIt++, tMin, tMax)) {
if (CollisionUtil::RayAABoxIntersection(xfRay, *aabbIt++, tMin, tMax) != 0u) {
CInternalRayCastStructure localCast(xfRay.start, xfRay.dir, mag, zeus::CTransform(), rayCast.GetFilter());
CRayCastResult localResult = obbTree.CastRayInternal(localCast);
if (localResult.IsValid()) {
@ -86,8 +86,8 @@ void CCollidableOBBTreeGroup::SetStaticTableIndex(u32 index) { sTableIndex = ind
bool CCollidableOBBTreeGroup::SphereCollide(const CInternalCollisionStructure& collision, CCollisionInfoList& list) {
bool ret = false;
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableOBBTreeGroup& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::COBBox obb1 = zeus::COBBox::FromAABox(p0.CalculateLocalAABox(), collision.GetRight().GetTransform().inverse() *
@ -96,16 +96,17 @@ bool CCollidableOBBTreeGroup::SphereCollide(const CInternalCollisionStructure& c
for (const std::unique_ptr<COBBTree>& tree : p1.x10_container->x0_trees) {
CCollidableOBBTree obbTree(tree.get(), p1.GetMaterial());
if (obbTree.SphereCollision(obbTree.x10_tree->GetRoot(), collision.GetRight().GetTransform(), s0, obb1,
p0.GetMaterial(), collision.GetLeft().GetFilter(), list))
p0.GetMaterial(), collision.GetLeft().GetFilter(), list)) {
ret = true;
}
}
return ret;
}
bool CCollidableOBBTreeGroup::SphereCollideBoolean(const CInternalCollisionStructure& collision) {
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableOBBTreeGroup& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::COBBox obb1 = zeus::COBBox::FromAABox(p0.CalculateLocalAABox(), collision.GetRight().GetTransform().inverse() *
@ -114,9 +115,10 @@ bool CCollidableOBBTreeGroup::SphereCollideBoolean(const CInternalCollisionStruc
for (const std::unique_ptr<COBBTree>& tree : p1.x10_container->x0_trees) {
CCollidableOBBTree obbTree(tree.get(), p1.GetMaterial());
if (obbTree.SphereCollisionBoolean(obbTree.x10_tree->GetRoot(), collision.GetRight().GetTransform(), s0, obb1,
collision.GetLeft().GetFilter()))
collision.GetLeft().GetFilter())) {
return true;
}
}
return false;
}
@ -124,8 +126,8 @@ bool CCollidableOBBTreeGroup::SphereCollideBoolean(const CInternalCollisionStruc
bool CCollidableOBBTreeGroup::CollideMovingSphere(const CInternalCollisionStructure& collision,
const zeus::CVector3f& dir, double& mag, CCollisionInfo& info) {
bool ret = false;
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableOBBTreeGroup& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
@ -141,9 +143,10 @@ bool CCollidableOBBTreeGroup::CollideMovingSphere(const CInternalCollisionStruct
CCollidableOBBTree obbTree(tree.get(), p1.GetMaterial());
CMetroidAreaCollider::ResetInternalCounters();
if (obbTree.SphereCollisionMoving(obbTree.x10_tree->GetRoot(), collision.GetRight().GetTransform(), s0, p0Obb,
p0.GetMaterial(), collision.GetLeft().GetFilter(), dir, mag, info))
p0.GetMaterial(), collision.GetLeft().GetFilter(), dir, mag, info)) {
ret = true;
}
}
return ret;
}
@ -178,8 +181,8 @@ bool CCollidableOBBTreeGroup::AABoxCollide(const CInternalCollisionStructure& co
}
bool CCollidableOBBTreeGroup::AABoxCollideBoolean(const CInternalCollisionStructure& collision) {
const CCollidableAABox& p0 = static_cast<const CCollidableAABox&>(collision.GetLeft().GetPrim());
const CCollidableOBBTreeGroup& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableAABox&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
zeus::CAABox b0 = p0.CalculateAABox(collision.GetLeft().GetTransform());
zeus::COBBox p0Obb = zeus::COBBox::FromAABox(p0.CalculateLocalAABox(), collision.GetRight().GetTransform().inverse() *
@ -188,9 +191,10 @@ bool CCollidableOBBTreeGroup::AABoxCollideBoolean(const CInternalCollisionStruct
for (const std::unique_ptr<COBBTree>& tree : p1.x10_container->x0_trees) {
CCollidableOBBTree obbTree(tree.get(), p1.GetMaterial());
if (obbTree.AABoxCollisionBoolean(obbTree.x10_tree->GetRoot(), collision.GetRight().GetTransform(), b0, p0Obb,
collision.GetLeft().GetFilter()))
collision.GetLeft().GetFilter())) {
return true;
}
}
return false;
}
@ -198,8 +202,8 @@ bool CCollidableOBBTreeGroup::AABoxCollideBoolean(const CInternalCollisionStruct
bool CCollidableOBBTreeGroup::CollideMovingAABox(const CInternalCollisionStructure& collision,
const zeus::CVector3f& dir, double& mag, CCollisionInfo& info) {
bool ret = false;
const CCollidableAABox& p0 = static_cast<const CCollidableAABox&>(collision.GetLeft().GetPrim());
const CCollidableOBBTreeGroup& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableAABox&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableOBBTreeGroup&>(collision.GetRight().GetPrim());
zeus::CAABox b0 = p0.CalculateAABox(collision.GetLeft().GetTransform());
@ -217,9 +221,10 @@ bool CCollidableOBBTreeGroup::CollideMovingAABox(const CInternalCollisionStructu
CCollidableOBBTree obbTree(tree.get(), p1.GetMaterial());
CMetroidAreaCollider::ResetInternalCounters();
if (obbTree.AABoxCollisionMoving(obbTree.x10_tree->GetRoot(), collision.GetRight().GetTransform(), b0, p0Obb,
p0.GetMaterial(), collision.GetLeft().GetFilter(), components, dir, mag, info))
p0.GetMaterial(), collision.GetLeft().GetFilter(), components, dir, mag, info)) {
ret = true;
}
}
return ret;
}

View File

@ -11,8 +11,8 @@ constexpr CCollisionPrimitive::Type sType(CCollidableSphere::SetStaticTableIndex
namespace Collide {
bool Sphere_AABox(const CInternalCollisionStructure& collision, CCollisionInfoList& list) {
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableAABox& p1 = static_cast<const CCollidableAABox&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableAABox&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::CAABox b1 = p1.Transform(collision.GetRight().GetTransform());
@ -39,7 +39,7 @@ bool Sphere_AABox(const CInternalCollisionStructure& collision, CCollisionInfoLi
}
}
if (!flags) {
if (flags == 0) {
zeus::CVector3f normal = (s0.position - b1.center()).normalized();
zeus::CVector3f point = s0.position + normal * s0.radius;
CCollisionInfo info(point, p0.GetMaterial(), p1.GetMaterial(), normal);
@ -47,8 +47,9 @@ bool Sphere_AABox(const CInternalCollisionStructure& collision, CCollisionInfoLi
return true;
}
if (distSq > s0.radius * s0.radius)
if (distSq > s0.radius * s0.radius) {
return false;
}
zeus::CVector3f point;
switch (flags) {
@ -140,8 +141,8 @@ bool Sphere_AABox(const CInternalCollisionStructure& collision, CCollisionInfoLi
}
bool Sphere_AABox_Bool(const CInternalCollisionStructure& collision) {
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableAABox& p1 = static_cast<const CCollidableAABox&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableAABox&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::CAABox b1 = p1.Transform(collision.GetRight().GetTransform());
@ -150,8 +151,8 @@ bool Sphere_AABox_Bool(const CInternalCollisionStructure& collision) {
}
bool Sphere_Sphere(const CInternalCollisionStructure& collision, CCollisionInfoList& list) {
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableSphere& p1 = static_cast<const CCollidableSphere&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableSphere&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::CSphere s1 = p1.Transform(collision.GetRight().GetTransform());
@ -172,8 +173,8 @@ bool Sphere_Sphere(const CInternalCollisionStructure& collision, CCollisionInfoL
}
bool Sphere_Sphere_Bool(const CInternalCollisionStructure& collision) {
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableSphere& p1 = static_cast<const CCollidableSphere&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableSphere&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::CSphere s1 = p1.Transform(collision.GetRight().GetTransform());
@ -205,8 +206,9 @@ zeus::CAABox CCollidableSphere::CalculateLocalAABox() const {
FourCC CCollidableSphere::GetPrimType() const { return SBIG('SPHR'); }
CRayCastResult CCollidableSphere::CastRayInternal(const CInternalRayCastStructure& rayCast) const {
if (!rayCast.GetFilter().Passes(GetMaterial()))
if (!rayCast.GetFilter().Passes(GetMaterial())) {
return {};
}
zeus::CSphere xfSphere = Transform(rayCast.GetTransform());
float t = 0.f;
@ -227,14 +229,15 @@ const CCollisionPrimitive::Type& CCollidableSphere::GetType() { return sType; }
bool CCollidableSphere::CollideMovingAABox(const CInternalCollisionStructure& collision, const zeus::CVector3f& dir,
double& dOut, CCollisionInfo& infoOut) {
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableAABox& p1 = static_cast<const CCollidableAABox&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableAABox&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::CAABox b1 = p1.CalculateAABox(collision.GetRight().GetTransform());
double d = dOut;
zeus::CVector3f point, normal;
zeus::CVector3f point;
zeus::CVector3f normal;
if (CollisionUtil::MovingSphereAABox(s0, b1, dir, d, point, normal) && d < dOut) {
dOut = d;
infoOut = CCollisionInfo(point, p0.GetMaterial(), p1.GetMaterial(), normal);
@ -246,8 +249,8 @@ bool CCollidableSphere::CollideMovingAABox(const CInternalCollisionStructure& co
bool CCollidableSphere::CollideMovingSphere(const CInternalCollisionStructure& collision, const zeus::CVector3f& dir,
double& dOut, CCollisionInfo& infoOut) {
const CCollidableSphere& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const CCollidableSphere& p1 = static_cast<const CCollidableSphere&>(collision.GetRight().GetPrim());
const auto& p0 = static_cast<const CCollidableSphere&>(collision.GetLeft().GetPrim());
const auto& p1 = static_cast<const CCollidableSphere&>(collision.GetRight().GetPrim());
zeus::CSphere s0 = p0.Transform(collision.GetLeft().GetTransform());
zeus::CSphere s1 = p1.Transform(collision.GetRight().GetTransform());

View File

@ -27,7 +27,7 @@ CCollisionActorManager::CCollisionActorManager(CStateManager& mgr, TUniqueId own
if (modDesc.GetNextId().IsInvalid()) {
// We only have the pivot id
const TUniqueId newId = mgr.AllocateUniqueId();
CCollisionActor* newAct;
CCollisionActor* newAct = nullptr;
if (modDesc.GetType() == CJointCollisionDescription::ECollisionType::Sphere) {
newAct = new CCollisionActor(newId, area, x10_ownerId, active, modDesc.GetRadius(), modDesc.GetMass(),

View File

@ -137,6 +137,16 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* regPipelinePmus = nullptr;
std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* redToAlphaPipelinePmus = nullptr;
if (gen.x26c_28_zTest) {
redToAlphaPipeline = &m_texRedToAlphaZTest;
regPipelineSub = &m_texZTestNoZWriteSub;
redToAlphaPipelineSub = &m_texRedToAlphaZTestSub;
} else {
redToAlphaPipeline = &m_texRedToAlphaNoZTest;
regPipelineSub = &m_texNoZTestNoZWriteSub;
redToAlphaPipelineSub = &m_texRedToAlphaNoZTestSub;
}
if (desc->x54_x40_TEXR) {
if (desc->x58_x44_TIND) {
if (desc->x45_30_x32_24_CIND) {
@ -159,16 +169,6 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
}
}
} else {
if (gen.x26c_28_zTest) {
redToAlphaPipeline = &m_texRedToAlphaZTest;
regPipelineSub = &m_texZTestNoZWriteSub;
redToAlphaPipelineSub = &m_texRedToAlphaZTestSub;
} else {
redToAlphaPipeline = &m_texRedToAlphaNoZTest;
regPipelineSub = &m_texNoZTestNoZWriteSub;
redToAlphaPipelineSub = &m_texRedToAlphaNoZTestSub;
}
if (gen.x26c_26_AAPH) {
if (gen.x26c_28_zTest)
regPipeline = &m_texAdditiveZTest;

View File

@ -5,10 +5,13 @@
#include "Runtime/CStateManager.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/World/CPlayer.hpp"
#include "Runtime/ImGuiEntitySupport.hpp"
#include "ImGuiEngine.hpp"
#include "magic_enum.hpp"
#include <zeus/CEulerAngles.hpp>
namespace ImGui {
// Internal functions
void ClearIniSettings();
@ -1057,6 +1060,7 @@ void ImGuiConsole::ShowAppMainMenuBar(bool canInspect) {
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Tools")) {
ImGui::MenuItem("Player Transform", nullptr, &m_showPlayerTransformEditor, canInspect && m_developer);
ImGui::MenuItem("Inspect", nullptr, &m_showInspectWindow, canInspect && m_developer);
ImGui::MenuItem("Items", nullptr, &m_showItemsWindow, canInspect && m_developer && m_cheats);
ImGui::MenuItem("Layers", nullptr, &m_showLayersWindow, canInspect && m_developer);
@ -1196,6 +1200,7 @@ void ImGuiConsole::PreUpdate() {
}
ShowDebugOverlay();
ShowInputViewer();
ShowPlayerTransformEditor();
}
void ImGuiConsole::PostUpdate() {
@ -1545,4 +1550,71 @@ void ImGuiConsole::ShowMenuHint() {
ImGui::PopStyleColor(2);
}
void ImGuiConsole::ShowPlayerTransformEditor() {
if (!m_showPlayerTransformEditor) {
return;
}
if (ImGui::Begin("Player Transform", &m_showPlayerTransformEditor, ImGuiWindowFlags_AlwaysAutoResize)) {
if (ImGui::CollapsingHeader("Position")) {
ImGui::PushID("player_position");
zeus::CVector3f vec = g_StateManager->GetPlayer().GetTranslation();
if (ImGuiVector3fInput("Position", vec)) {
g_StateManager->GetPlayer().SetTranslation(vec);
}
if (ImGui::Button("Save")) {
m_savedLocation.emplace(vec);
}
ImGui::SameLine();
if (ImGui::Button("Load") && m_savedLocation) {
g_StateManager->GetPlayer().SetTranslation(*m_savedLocation);
}
ImGui::SameLine();
if (ImGui::Button("Clear") && m_savedLocation) {
m_savedLocation.reset();
}
if (m_savedLocation) {
ImGui::Text("Saved: %g, %g, %g", float(m_savedLocation->x()), float(m_savedLocation->y()),
float(m_savedLocation->z()));
}
ImGui::PopID();
}
if (ImGui::CollapsingHeader("Rotation")) {
ImGui::PushID("player_rotation");
zeus::CEulerAngles angles(g_StateManager->GetPlayer().GetTransform());
angles = zeus::CEulerAngles(angles * zeus::skRadToDegVec);
if (ImGuiVector3fInput("Rotation", angles)) {
angles.x() = zeus::clamp(-179.999f, float(angles.x()), 179.999f);
angles.y() = zeus::clamp(-89.999f, float(angles.y()), 89.999f);
angles.z() = zeus::clamp(-179.999f, float(angles.z()), 179.999f);
auto xf = g_StateManager->GetPlayer().GetTransform();
xf.setRotation(zeus::CQuaternion(angles * zeus::skDegToRadVec).toTransform().buildMatrix3f());
g_StateManager->GetPlayer().SetTransform(xf);
}
if (ImGui::Button("Save")) {
m_savedRotation.emplace(angles);
}
ImGui::SameLine();
if (ImGui::Button("Load") && m_savedRotation) {
auto xf = g_StateManager->GetPlayer().GetTransform();
xf.setRotation(zeus::CQuaternion((*m_savedRotation) * zeus::skDegToRadVec).toTransform().buildMatrix3f());
g_StateManager->GetPlayer().SetTransform(xf);
}
ImGui::SameLine();
if (ImGui::Button("Clear") && m_savedRotation) {
m_savedRotation.reset();
}
if (m_savedRotation) {
ImGui::Text("Saved: %g, %g, %g", float(m_savedRotation->x()), float(m_savedRotation->y()),
float(m_savedRotation->z()));
}
ImGui::PopID();
}
}
ImGui::End();
}
} // namespace metaforce

View File

@ -11,6 +11,8 @@
#include "hecl/CVarCommons.hpp"
#include "hecl/CVarManager.hpp"
#include <zeus/CEulerAngles.hpp>
namespace metaforce {
void ImGuiStringViewText(std::string_view text);
void ImGuiTextCenter(std::string_view text);
@ -57,6 +59,9 @@ private:
bool m_showItemsWindow = false;
bool m_showLayersWindow = false;
bool m_showConsoleVariablesWindow = false;
bool m_showPlayerTransformEditor = false;
std::optional<zeus::CVector3f> m_savedLocation;
std::optional<zeus::CEulerAngles> m_savedRotation;
bool m_paused = false;
bool m_stepFrame = false;
@ -106,5 +111,6 @@ private:
void ShowInputViewer();
void SetOverlayWindowLocation(int corner) const;
void ShowCornerContextMenu(int& corner, int avoidCorner) const;
void ShowPlayerTransformEditor();
};
} // namespace metaforce

View File

@ -1,3 +1,5 @@
#include "Runtime/ImGuiEntitySupport.hpp"
#include "Runtime/World/CActor.hpp"
#include "Runtime/World/CAi.hpp"
#include "Runtime/World/CAmbientAI.hpp"
@ -178,7 +180,9 @@
} \
}
static bool ImGuiVector3fInput(const char* label, zeus::CVector3f& vec) {
namespace metaforce {
bool ImGuiVector3fInput(const char* label, zeus::CVector3f& vec) {
std::array<float, 3> arr{vec.x(), vec.y(), vec.z()};
if (ImGui::DragFloat3(label, arr.data(), 0.1f)) {
vec.assign(arr[0], arr[1], arr[2]);
@ -221,7 +225,6 @@ void ImGuiAnimRes(const char* label, metaforce::CAnimRes& res) {
// TODO: More
}
namespace metaforce {
void CDamageVulnerability::ImGuiEditWindow(const char* title, bool& open) {
if (!open) {
return;

View File

@ -1 +1,7 @@
#pragma once
#include <zeus/CVector3f.hpp>
namespace metaforce {
bool ImGuiVector3fInput(const char* label, zeus::CVector3f& vec);
}

View File

@ -124,25 +124,7 @@ std::array<std::array<s32, 3>, 14> skSomeMeleeValues{{
{{0, 0, 0}},
}};
std::array<s32, 17> skSomeValues1{{
7,
5,
18,
18,
18,
18,
18,
18,
18,
7,
5,
7,
17,
18,
9,
2,
11,
}};
std::array<s32, 17> skSomeValues1{{7, 5, 18, 18, 18, 18, 18, 18, 18, 7, 5, 7, 17, 18, 9, 2, 11}};
std::array<std::array<pas::ELocomotionType, 3>, 14> skSomeValues2{{
{{pas::ELocomotionType::Invalid, pas::ELocomotionType::Invalid, pas::ELocomotionType::Invalid}},
@ -344,13 +326,13 @@ void CMetroidPrimeExo::Think(float dt, CStateManager& mgr) {
UpdateColorChange(dt, mgr);
UpdateHeadAnimation(dt);
UpdatePlasmaProjectile(dt, mgr);
sub80274e6c(dt, mgr);
UpdateParticles(dt, mgr);
UpdateEnergyBalls(dt, mgr);
UpdatePhysicsDummy(mgr);
UpdateContactDamage(mgr);
UpdateTimers(dt);
UpdateSfxEmitter(dt, mgr);
sub80275e54(dt, mgr);
UpdateElectricEffect(dt, mgr);
}
void CMetroidPrimeExo::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId other, CStateManager& mgr) {
@ -452,7 +434,9 @@ bool CMetroidPrimeExo::CanRenderUnsorted(const CStateManager& mgr) const {
return mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::XRay;
}
void CMetroidPrimeExo::Touch(CActor& act, CStateManager& mgr) { CPatterned::Touch(act, mgr); }
void CMetroidPrimeExo::Touch(CActor& act, CStateManager& mgr) {
// Empty
}
void CMetroidPrimeExo::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
if (type == EUserEventType::ScreenShake) {
@ -519,7 +503,7 @@ void CMetroidPrimeExo::Run(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x92c_ = 10;
x1084_ = 1.9666666f;
TUniqueId wpId = sub802769e0(mgr, true);
TUniqueId wpId = GetNextAttackWaypoint(mgr, true);
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(wpId)) {
GetBodyController()->SetLocomotionType(sub80275e14(1));
SetDestPos(wp->GetTranslation());
@ -560,6 +544,8 @@ void CMetroidPrimeExo::TurnAround(CStateManager& mgr, EStateMsg msg, float arg)
x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryStep, 3);
x450_bodyController->SetLocomotionType(skLocomotions[x1078_]);
x1078_ = 1;
zeus::CVector3f vec = sub8027464c(mgr);
if ((vec - GetTranslation()).normalized().dot(mgr.GetPlayer().GetTranslation() - GetTranslation()) < 15.f) {
sub802747b8(arg, mgr, vec);
@ -700,7 +686,7 @@ void CMetroidPrimeExo::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float
x32c_animState = EAnimState::NotReady;
x92c_ = 0;
sub802738d4(mgr);
x1088_ = 1.2166667;
x1088_ = 1.2166667f;
xc50_->SetParticleEmission(false);
FirePlasmaProjectile(mgr, false);
x1254_ = 2;
@ -745,7 +731,7 @@ void CMetroidPrimeExo::Retreat(CStateManager& mgr, EStateMsg msg, float arg) {
x32c_animState = EAnimState::Ready;
SendStateToRelay(EScriptObjectState::Zero, mgr);
if (TCastToConstPtr<CScriptWaypoint> wp =
mgr.GetObjectById(sub80276b3c(mgr, EScriptObjectState::CloseIn, EScriptObjectMessage::Follow))) {
mgr.GetObjectById(GetWaypointForBehavior(mgr, EScriptObjectState::CloseIn, EScriptObjectMessage::Follow))) {
SetTransform(wp->GetTransform());
}
x1078_ = 1;
@ -755,7 +741,7 @@ void CMetroidPrimeExo::Retreat(CStateManager& mgr, EStateMsg msg, float arg) {
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
if (TCastToConstPtr<CScriptWaypoint> wp =
mgr.GetObjectById(sub80276b3c(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) {
mgr.GetObjectById(GetWaypointForBehavior(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) {
SetTransform(wp->GetTransform());
}
++x91c_;
@ -936,7 +922,24 @@ u32 CMetroidPrimeExo::CountEnergyBalls(CStateManager& mgr) {
return ret;
}
void CMetroidPrimeExo::sub80273d38(CStateManager& mgr) {}
void CMetroidPrimeExo::DeactivatePatrolObjects(CStateManager& mgr) {
const TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId);
x1058_.clear();
if (relay) {
for (const auto& conn : relay->GetConnectionList()) {
if (conn.x0_state != EScriptObjectState::Patrol) {
continue;
}
if (auto* ent = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
ent->AcceptScriptMsg(EScriptObjectMessage::Deactivate, GetUniqueId(), mgr);
x1058_.push_back(conn.x8_objId);
if (x1058_.size() >= 4) {
break;
}
}
}
}
}
void CMetroidPrimeExo::UpdatePhysicsDummy(CStateManager& mgr) {
if (TCastToPtr<CPhysicsActor> physAct = mgr.ObjectById(xeac_)) {
@ -972,7 +975,7 @@ void CMetroidPrimeExo::SetBillboardEmission(CStateManager& mgr, bool emission) {
void CMetroidPrimeExo::FreeBillboard(CStateManager& mgr) { mgr.FreeScriptObject(x1044_billboardId); }
zeus::CVector3f CMetroidPrimeExo::sub8027464c(CStateManager& mgr) {
TUniqueId uid = sub80276b3c(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
TUniqueId uid = GetWaypointForBehavior(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
float dVar4 = 0.f;
zeus::CVector3f tmpVec;
@ -1015,9 +1018,61 @@ void CMetroidPrimeExo::sub802747b8(float f1, CStateManager& mgr, const zeus::CVe
}
void CMetroidPrimeExo::sub802749e8(float f1, float f2, float f3, const zeus::CVector3f& vec1,
const zeus::CVector3f& vec2) {}
const zeus::CVector3f& vec2, s32 idx) {
auto diffVec = vec2 - vec1;
const float dist = diffVec.magnitude();
const auto& elemGen = xfec_[idx];
const auto& swooshGen = x1000_[idx];
void CMetroidPrimeExo::sub80274e6c(float f1, CStateManager& mgr) {
if (!zeus::close_enough(diffVec, zeus::skZero3f)) {
zeus::CVector3f v1 = vec1;
auto lookAtXf = zeus::lookAt(zeus::skZero3f, diffVec);
elemGen->SetParticleEmission(true);
s32 count = static_cast<s32>(2.f * dist + 1.f);
for (s32 i = 0; i < count; ++i) {
float dVar14 = i * static_cast<int>(1.f / static_cast<float>(count));
float dVar11 = f1 * (dVar14 * std::cos(static_cast<float>(i) + f3));
float fVar15 = static_cast<float>(std::sin(i));
const auto v = (i < 1) ? zeus::skZero3f : lookAtXf * zeus::CVector3f{dVar11, 0.f, f2 * (dVar14 * fVar15)};
elemGen->SetTranslation(v1 + v);
elemGen->ForceParticleCreation(1);
v1 += v1 + diffVec;
}
elemGen->SetParticleEmission(false);
auto& swooshes = swooshGen->GetSwooshes();
count = swooshes.size() - 1;
v1 = vec1;
float fVar14 = vec1.x();
float fVar1 = vec1.y();
float fVar2 = vec1.z();
float fVar3 = swooshes[count].x30_irot;
float dVar12 = 1.f / static_cast<float>(count);
diffVec = diffVec * dVar12;
for (s32 i = 0; i <= count; ++i) {
float vec1Z = fVar3;
float dVar13 = fVar2;
float vec1X = fVar1;
float vec1Y = fVar14;
float dVar9 = static_cast<float>(i) * dVar12;
fVar14 = std::cos(static_cast<float>(i) + f3);
float dVar11 = f1 * (dVar9 * fVar14);
fVar14 = std::sin(i);
const auto v = (i < 1) ? zeus::skZero3f : lookAtXf * zeus::CVector3f{dVar11, 0.f, f2 * (dVar9 * fVar14)};
swooshes[i].xc_translation = {vec1Y + v.x(), vec1X + fVar14, dVar13 + fVar1};
swooshes[i].x38_orientation = lookAtXf;
fVar3 = swooshes[i].x30_irot;
fVar14 = vec1Y + diffVec.x();
fVar1 = vec1X + diffVec.y();
swooshes[i].x30_irot = vec1Z;
fVar2 = dVar13 + diffVec.z();
}
}
}
void CMetroidPrimeExo::UpdateParticles(float f1, CStateManager& mgr) {
if (GetBodyController()->GetPercentageFrozen() > 0.f && x1054_24_) {
sub802755ac(mgr, false);
x1054_25_ = true;
@ -1040,7 +1095,7 @@ void CMetroidPrimeExo::sub80274e6c(float f1, CStateManager& mgr) {
float dVar12 = 1.f - dVar13;
float tmp = zeus::clamp(0.f, 0.5f + (x102c_[i] / 0.3f), 1.f);
zeus::CVector3f local_154 = off * dVar12 + (xf.origin * dVar13);
sub802749e8(2.f * tmp, 0.5f * tmp, x1038_[i], xf.origin, local_154);
sub802749e8(2.f * tmp, 0.5f * tmp, x1038_[i], xf.origin, local_154, i);
if (tmp <= 0.f) {
if (mgr.RayCollideWorld(xf.origin, local_154,
CMaterialFilter::MakeIncludeExclude(
@ -1055,7 +1110,7 @@ void CMetroidPrimeExo::sub80274e6c(float f1, CStateManager& mgr) {
} else if (CParticleSwoosh::GetAliveParticleSystemCount() != 0) {
float tmp1 = zeus::clamp(0.f, 3.f * (x102c_[i] / 0.3f) - 2.f, 1.f);
float tmp2 = zeus::clamp(0.f, 0.5f + (x102c_[i] / 0.3f), 1.f);
sub802749e8(tmp2, tmp2, x1038_[i], xf.origin, xf.origin * (1.f - tmp1) + (off * tmp1));
sub802749e8(tmp2, tmp2, x1038_[i], xf.origin, xf.origin * (1.f - tmp1) + (off * tmp1), i);
x1000_[i]->Update(f1);
}
xfec_[i]->Update(f1);
@ -1140,7 +1195,7 @@ void CMetroidPrimeExo::UpdateTimers(float dt) {
}
void CMetroidPrimeExo::sub80275800(CStateManager& mgr) {
TUniqueId tmpId = sub802769e0(mgr, true);
TUniqueId tmpId = GetNextAttackWaypoint(mgr, true);
u32 flags = 0x13c1;
if (tmpId != kInvalidUniqueId) {
@ -1261,7 +1316,7 @@ pas::ELocomotionType CMetroidPrimeExo::sub80275e14(int w1) { return skSomeValues
u32 CMetroidPrimeExo::sub80275e34(int w1) const { return skSomeMeleeValues[w1][x1078_]; }
void CMetroidPrimeExo::sub80275e54(float dt, CStateManager& mgr) {
void CMetroidPrimeExo::UpdateElectricEffect(float dt, CStateManager& mgr) {
if (!xfac_) {
return;
}
@ -1394,7 +1449,7 @@ void CMetroidPrimeExo::SendStateToRelay(EScriptObjectState state, CStateManager&
}
}
void CMetroidPrimeExo::sub80276754(CStateManager& mgr) {
void CMetroidPrimeExo::GetRelayState(CStateManager& mgr) {
x1160_.clear();
if (TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId)) {
x1160_ = relay->GetRoomParameters();
@ -1412,8 +1467,8 @@ void CMetroidPrimeExo::sub80276754(CStateManager& mgr) {
}
}
TUniqueId CMetroidPrimeExo::sub802769e0(CStateManager& mgr, bool b1) {
TUniqueId uid = sub80276b3c(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
TUniqueId CMetroidPrimeExo::GetNextAttackWaypoint(CStateManager& mgr, bool b1) {
TUniqueId uid = GetWaypointForBehavior(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow);
float lastDot = 0.f;
TUniqueId lastUid = kInvalidUniqueId;
while (uid != kInvalidUniqueId) {
@ -1433,7 +1488,7 @@ TUniqueId CMetroidPrimeExo::sub802769e0(CStateManager& mgr, bool b1) {
return lastUid;
}
TUniqueId CMetroidPrimeExo::sub80276b3c(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg) {
TUniqueId CMetroidPrimeExo::GetWaypointForBehavior(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg) {
if (TCastToConstPtr<CMetroidPrimeRelay> relay = mgr.GetObjectById(x568_relayId)) {
rstl::reserved_vector<TUniqueId, 8> uids;
for (const auto& conn : relay->GetConnectionList()) {
@ -1483,8 +1538,8 @@ void CMetroidPrimeExo::UpdateRelay(CStateManager& mgr, TAreaId areaId) {
}
}
sub80276754(mgr);
sub80273d38(mgr);
GetRelayState(mgr);
DeactivatePatrolObjects(mgr);
}
bool CMetroidPrimeExo::IsRelayValid(CStateManager& mgr, TAreaId aid) {
@ -1502,15 +1557,12 @@ bool CMetroidPrimeExo::IsRelayValid(CStateManager& mgr, TAreaId aid) {
}
bool CMetroidPrimeExo::sub80277224(float f1, CStateManager& mgr) {
TUniqueId uid = sub802769e0(mgr, f1 >= 0.f);
TUniqueId uid = GetNextAttackWaypoint(mgr, f1 >= 0.f);
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(uid)) {
const float dist = (wp->GetTranslation() - GetTranslation()).magSquared();
const float scaleMag = f1 * (0.57735026f * GetModelData()->GetScale().magSquared());
if (f1 < 0.f) {
return dist > scaleMag;
}
return dist < scaleMag;
const float scaleMag = f1 * (0.57735026 * GetModelData()->GetScale().magnitude());
const float dist = GetTransform().frontVector().dot(wp->GetTranslation() - GetTranslation());
return f1 < 0.f ? dist < scaleMag : dist > scaleMag;
}
return false;
}
@ -1730,7 +1782,7 @@ void CMetroidPrimeExo::sub80278508(CStateManager& mgr, int w1, bool b1) {
x570_ = w1;
sub80278130(x588_[x570_].x6c_color);
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(x8cc_headColActor)) {
if (b1 == false) {
if (!b1) {
colAct->SetDamageVulnerability(CDamageVulnerability::ImmuneVulnerabilty());
mgr.GetPlayer().SetOrbitRequestForTarget(GetUniqueId(), CPlayer::EPlayerOrbitRequest::ActivateOrbitSource, mgr);
colAct->RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);

View File

@ -182,6 +182,7 @@ class CMetroidPrimeExo : public CPatterned {
bool x1054_25_ : 1 = false;
bool x1054_26_ : 1 = false;
bool x1054_27_ : 1 = false;
rstl::reserved_vector<TEditorId, 4> x1058_;
rstl::reserved_vector<TUniqueId, 2> x106c_energyBallIds;
float x1074_ = 0.f;
s32 x1078_ = -1;
@ -203,7 +204,7 @@ class CMetroidPrimeExo : public CPatterned {
void sub802738d4(CStateManager& mgr);
void UpdateEnergyBalls(float dt, CStateManager& mgr);
u32 CountEnergyBalls(CStateManager& mgr);
void sub80273d38(CStateManager& mgr);
void DeactivatePatrolObjects(CStateManager& mgr);
void UpdatePhysicsDummy(CStateManager& mgr);
void sub80274054(CStateManager& mgr);
void sub802740cc(CStateManager& mgr);
@ -213,8 +214,8 @@ class CMetroidPrimeExo : public CPatterned {
zeus::CVector3f sub8027464c(CStateManager& mgr);
void CreateHUDBillBoard(CStateManager& mgr);
void sub802747b8(float f1, CStateManager& mgr, const zeus::CVector3f& vec);
void sub802749e8(float f1, float f2, float f3, const zeus::CVector3f& vec1, const zeus::CVector3f& vec2);
void sub80274e6c(float f1, CStateManager& mgr);
void sub802749e8(float f1, float f2, float f3, const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, s32 idx);
void UpdateParticles(float f1, CStateManager& mgr);
void sub802755ac(CStateManager& mgr, bool b1);
void EnableHeadOrbitAndTarget(CStateManager& mgr);
void DisableHeadOrbitAndTarget(CStateManager& mgr);
@ -227,16 +228,16 @@ class CMetroidPrimeExo : public CPatterned {
bool sub80275d68(int w1);
pas::ELocomotionType sub80275e14(int w1);
u32 sub80275e34(int w1) const;
void sub80275e54(float f1, CStateManager& mgr);
void UpdateElectricEffect(float dt, CStateManager& mgr);
void UpdateSfxEmitter(float f1, CStateManager& mgr);
void sub80276204(CStateManager& mgr, bool b1);
void sub8027639c(CStateManager& mgr, bool b1);
void SetActorAreaId(CStateManager& mgr, TUniqueId uid, TAreaId aid);
void UpdateAreaId(CStateManager& mgr);
void SendStateToRelay(EScriptObjectState state, CStateManager& mgr);
void sub80276754(CStateManager& mgr);
TUniqueId sub802769e0(CStateManager& mgr, bool b1);
TUniqueId sub80276b3c(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg);
void GetRelayState(CStateManager& mgr);
TUniqueId GetNextAttackWaypoint(CStateManager& mgr, bool b1);
TUniqueId GetWaypointForBehavior(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg);
void UpdateRelay(CStateManager& mgr, TAreaId areaId);
bool IsRelayValid(CStateManager& mgr, TAreaId w2);
bool sub80277224(float f1, CStateManager& mgr);

View File

@ -41,18 +41,18 @@ public:
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override;
[[nodiscard]] TUniqueId GetMetroidPrimeExoId() const { return x34_mpUid; }
void SetMetroidPrimeExoId(TUniqueId uid) { x34_mpUid = uid; }
float Get_xc84() const { return xc84_f1; }
float Get_xc88() const { return xc88_f2; }
float Get_xc8c() const { return xc8c_f3; }
u32 Get_xc90() const { return xc90_w1; }
bool Get_xc94() const { return xc94_b1; }
u32 Get_xc98() const { return xc98_w2; }
CHealthInfo GetHealthInfo1() const { return xc9c_hInfo1; }
CHealthInfo GetHealthInfo2() const { return xca4_hInfo2; }
u32 Get_xcac() const { return xcac_w3; }
u32 Get_xcb0() const { return xcb0_w4; }
u32 Get_xcb4() const { return xcb4_w5; }
rstl::reserved_vector<SPrimeExoRoomParameters, 4> GetRoomParameters() const { return xcb8_roomParms; }
[[nodiscard]] float Get_xc84() const { return xc84_f1; }
[[nodiscard]] float Get_xc88() const { return xc88_f2; }
[[nodiscard]] float Get_xc8c() const { return xc8c_f3; }
[[nodiscard]] u32 Get_xc90() const { return xc90_w1; }
[[nodiscard]] bool Get_xc94() const { return xc94_b1; }
[[nodiscard]] u32 Get_xc98() const { return xc98_w2; }
[[nodiscard]] CHealthInfo GetHealthInfo1() const { return xc9c_hInfo1; }
[[nodiscard]] CHealthInfo GetHealthInfo2() const { return xca4_hInfo2; }
[[nodiscard]] u32 Get_xcac() const { return xcac_w3; }
[[nodiscard]] u32 Get_xcb0() const { return xcb0_w4; }
[[nodiscard]] u32 Get_xcb4() const { return xcb4_w5; }
[[nodiscard]] rstl::reserved_vector<SPrimeExoRoomParameters, 4> GetRoomParameters() const { return xcb8_roomParms; }
};
} // namespace metaforce::MP1

View File

@ -815,7 +815,7 @@ void CThardus::PathFind(CStateManager& mgr, EStateMsg msg, float arg) {
void CThardus::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
if (x95e_) {
return;
}
@ -823,31 +823,31 @@ void CThardus::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg) {
mgr.SetBossParams(GetUniqueId(), GetHealthInfo(mgr)->GetHP(), 88);
x95e_ = true;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Taunt) {
x5ec_ = 2;
x5ec_stateProg = 2;
} else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCTauntCmd(pas::ETauntType::One));
}
} else if (x5ec_ == 2 &&
} else if (x5ec_stateProg == 2 &&
x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Taunt) {
x5ec_ = 3;
x5ec_stateProg = 3;
}
}
}
void CThardus::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Getup) {
x5ec_ = 2;
x5ec_stateProg = 2;
} else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGetupCmd(pas::EGetupType::Zero));
}
} else if (x5ec_ == 2 && x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Getup) {
x5ec_ = 3;
} else if (x5ec_stateProg == 2 && x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Getup) {
x5ec_stateProg = 3;
}
} else if (msg == EStateMsg::Deactivate) {
x93d_ = false;
@ -856,11 +856,11 @@ void CThardus::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
void CThardus::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
++x570_;
x5ec_ = 0;
x5ec_stateProg = 0;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
if (mgr.GetActiveRandom()->Float() <= 0.5f) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(pas::ESeverity::One));
@ -869,10 +869,10 @@ void CThardus::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
}
++x570_;
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 && GetBodyController()->GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
x5ec_ = 3;
} else if (x5ec_stateProg == 2 && GetBodyController()->GetCurrentStateId() != pas::EAnimationState::MeleeAttack) {
x5ec_stateProg = 3;
}
}
}
@ -941,16 +941,16 @@ void CThardus::GetUp(CStateManager& mgr, EStateMsg msg, float arg) {
void CThardus::Taunt(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Taunt) {
x5ec_ = 2;
x5ec_stateProg = 2;
} else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCTauntCmd(pas::ETauntType::One));
}
} else if (x5ec_ == 2 && x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Taunt) {
x5ec_ = 3;
} else if (x5ec_stateProg == 2 && x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Taunt) {
x5ec_stateProg = 3;
}
}
}
@ -967,28 +967,29 @@ void CThardus::Suck(CStateManager& mgr, EStateMsg msg, float arg) {
void CThardus::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 1) {
if (x5ec_stateProg == 1) {
return;
}
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::ProjectileAttack) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBCProjectileAttackCmd(pas::ESeverity::Zero, {}, false));
x5ec_ = 0;
x5ec_stateProg = 0;
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 &&
} else if (x5ec_stateProg == 2 &&
GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::ProjectileAttack) {
x5ec_ = 3;
x5ec_stateProg = 3;
}
}
}
void CThardus::Flinch(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_stateProg = 0;
for (TUniqueId uid : x798_) {
if (auto* rock = CPatterned::CastTo<CThardusRockProjectile>(mgr.ObjectById(uid))) {
rock->sub80203d58();
@ -1025,56 +1026,56 @@ void CThardus::Flinch(CStateManager& mgr, EStateMsg msg, float arg) {
break;
}
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::KnockBack) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBCKnockBackCmd({}, severity));
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 &&
} else if (x5ec_stateProg == 2 &&
GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::KnockBack) {
x5ec_ = 3;
x5ec_stateProg = 3;
}
}
}
void CThardus::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::ProjectileAttack) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBCProjectileAttackCmd(pas::ESeverity::One, {}, false));
x5ec_ = 0;
x5ec_stateProg = 0;
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 &&
} else if (x5ec_stateProg == 2 &&
GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::ProjectileAttack) {
x5ec_ = 3;
x5ec_stateProg = 3;
}
}
}
void CThardus::Explode(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
CSfxManager::SfxStop(x904_);
x909_ = true;
x93d_ = true;
x909_ = true;
SendScriptMsgs(EScriptObjectState::Arrived, mgr, EScriptObjectMessage::None);
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Step) {
GetBodyController()->GetCommandMgr().DeliverCmd(
CBCStepCmd(pas::EStepDirection::Forward, pas::EStepType::Dodge));
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 &&
} else if (x5ec_stateProg == 2 &&
GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Step) {
x5ec_ = 3;
x5ec_stateProg = 3;
}
} else if (msg == EStateMsg::Deactivate) {
x8f0_ = true;
@ -1099,19 +1100,19 @@ void CThardus::Cover(CStateManager& mgr, EStateMsg msg, float arg) {
void CThardus::Enraged(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
x688_ = true;
x908_ = true;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Taunt) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBCTauntCmd(pas::ETauntType::Zero));
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 &&
} else if (x5ec_stateProg == 2 &&
GetBodyController()->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Taunt) {
x5ec_ = 3;
x5ec_stateProg = 3;
}
} else if (msg == EStateMsg::Deactivate) {
x908_ = false;
@ -1120,18 +1121,18 @@ void CThardus::Enraged(CStateManager& mgr, EStateMsg msg, float arg) {
void CThardus::Growth(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
x904_ = CSfxManager::SfxStart(SFXsfx07AD, 1.f, 0.f, false, 0x7f, true, GetAreaIdAlways());
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetCurrentStateId() != pas::EAnimationState::Step) {
GetBodyController()->GetCommandMgr().DeliverCmd(
CBCStepCmd(pas::EStepDirection::Forward, pas::EStepType::BreakDodge));
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 && GetBodyController()->GetCurrentStateId() != pas::EAnimationState::Step) {
x5ec_ = 3;
} else if (x5ec_stateProg == 2 && GetBodyController()->GetCurrentStateId() != pas::EAnimationState::Step) {
x5ec_stateProg = 3;
}
} else if (msg == EStateMsg::Deactivate) {
if (TCastToPtr<CScriptDistanceFog> fog = mgr.ObjectById(x64c_fog)) {
@ -1144,7 +1145,7 @@ void CThardus::Growth(CStateManager& mgr, EStateMsg msg, float arg) {
void CThardus::Faint(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
x5ec_stateProg = 0;
x93c_ = false;
SetState(-1, mgr);
for (TUniqueId uid : x798_) {
@ -1154,14 +1155,14 @@ void CThardus::Faint(CStateManager& mgr, EStateMsg msg, float arg) {
}
x94d_ = true;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x5ec_stateProg == 0) {
if (GetBodyController()->GetCurrentStateId() != pas::EAnimationState::KnockBack) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBCKnockBackCmd({}, pas::ESeverity::Six));
} else {
x5ec_ = 2;
x5ec_stateProg = 2;
}
} else if (x5ec_ == 2 && GetBodyController()->GetCurrentStateId() != pas::EAnimationState::KnockBack) {
x5ec_ = 3;
} else if (x5ec_stateProg == 2 && GetBodyController()->GetCurrentStateId() != pas::EAnimationState::KnockBack) {
x5ec_stateProg = 3;
}
}
}
@ -1173,7 +1174,7 @@ bool CThardus::InRange(CStateManager& mgr, float arg) {
}
bool CThardus::PatternOver(CStateManager& mgr, float arg) { return x570_ != 0 || x93b_; }
bool CThardus::AnimOver(CStateManager& mgr, float arg) { return x5ec_ == 3; }
bool CThardus::AnimOver(CStateManager& mgr, float arg) { return x5ec_stateProg == 3; }
bool CThardus::InPosition(CStateManager& mgr, float arg) { return x660_ > 3; }
bool CThardus::ShouldTurn(CStateManager& mgr, float arg) {
return std::fabs(zeus::CVector2f::getAngleDiff(GetTransform().frontVector().toVec2f(),

View File

@ -30,7 +30,7 @@ class CThardus : public CPatterned {
* to the use of move semantics to prevent deep copies */
std::vector<CStaticRes> x5cc_;
std::vector<CStaticRes> x5dc_;
s32 x5ec_ = -1;
s32 x5ec_stateProg = -1;
std::unique_ptr<CCollisionActorManager> x5f0_rockColliders;
std::unique_ptr<CCollisionActorManager> x5f4_;
std::unique_ptr<CCollisionActorManager> x5f8_;

2
extern/imgui vendored

@ -1 +1 @@
Subproject commit 8877eab3933c7031e2b41f372b852618db219489
Subproject commit 23a15834fa23226bd26a17f5142b00678617fec4

2
extern/zeus vendored

@ -1 +1 @@
Subproject commit bb9b4c83af12647df1db7978347bd297dda3277b
Subproject commit f3630be9dee64378e7bcf20b4602b64bd8c810c0

View File

@ -275,6 +275,11 @@ def recursive_cook(buffer, obj, version, path_hasher, parent_name):
def cook(writepipebuf, version, path_hasher):
global hjustifications, vjustifications, model_draw_flags_e
if bpy.app.version >= (2, 93, 0):
hjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_hjustification.keywords['items'])
vjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_vjustification.keywords['items'])
model_draw_flags_e = dict((i[0], i[3]) for i in bpy.types.Object.retro_widget_model_draw_flags.keywords['items'])
else:
hjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_hjustification[1]['items'])
vjustifications = dict((i[0], i[3]) for i in bpy.types.Object.retro_textpane_vjustification[1]['items'])
model_draw_flags_e = dict((i[0], i[3]) for i in bpy.types.Object.retro_widget_model_draw_flags[1]['items'])
@ -320,7 +325,7 @@ def register():
('RETRO_ADDITIVE', 'Additive', '', 3),
('RETRO_ALPHA_ADDITIVE_OVERDRAW', 'Alpha Additive Overdraw', '', 4)]
bpy.types.Object.retro_widget_parent = bpy.props.StringProperty(name='Retro: FRME Widget Parent', description='Refers to internal frame widgets')
bpy.types.Object.retro_widget_use_anim_controller = bpy.props.BoolProperty(name='Retro: Use Animiation Conroller')
bpy.types.Object.retro_widget_use_anim_controller = bpy.props.BoolProperty(name='Retro: Use Animation Controller')
bpy.types.Object.retro_widget_default_visible = bpy.props.BoolProperty(name='Retro: Default Visible', description='Sets widget is visible by default')
bpy.types.Object.retro_widget_default_active = bpy.props.BoolProperty(name='Retro: Default Active', description='Sets widget is cases by default')
bpy.types.Object.retro_widget_cull_faces = bpy.props.BoolProperty(name='Retro: Cull Faces', description='Enables face culling')

View File

@ -249,10 +249,16 @@ def cook(writebuf, mesh_obj):
if mesh_obj.type != 'MESH':
raise RuntimeError("%s is not a mesh" % mesh_obj.name)
if bpy.app.version >= (2, 93, 0):
obj_vismodes = dict((i[0], i[3]) for i in bpy.types.Object.retro_mapobj_vis_mode.keywords['items'])
else:
obj_vismodes = dict((i[0], i[3]) for i in bpy.types.Object.retro_mapobj_vis_mode[1]['items'])
# Write out visibility type
if hasattr(bpy.types.Scene.retro_map_vis_mode, '__getitem__'):
vis_types = dict((i[0], i[3]) for i in bpy.types.Scene.retro_map_vis_mode[1]['items'])
else:
vis_types = dict((i[0], i[3]) for i in bpy.types.Scene.retro_map_vis_mode.keywords['items'])
writebuf(struct.pack('I', vis_types[bpy.context.scene.retro_map_vis_mode]))
# Copy mesh (and apply mesh modifiers with triangulation)

View File

@ -6,7 +6,7 @@ namespace hecl::blender {
constexpr uint32_t MinBlenderMajorSearch = 2;
constexpr uint32_t MaxBlenderMajorSearch = 2;
constexpr uint32_t MinBlenderMinorSearch = 83;
constexpr uint32_t MaxBlenderMinorSearch = 92;
constexpr uint32_t MaxBlenderMinorSearch = 93;
std::optional<std::string> FindBlender(int& major, int& minor);

View File

@ -11,7 +11,6 @@
namespace hecl {
namespace DNACVAR {
enum class EType : atUint8 { Boolean, Signed, Unsigned, Real, Literal, Vec2f, Vec2d, Vec3f, Vec3d, Vec4f, Vec4d };
enum class EFlags {
None = 0,
System = (1 << 0),
@ -48,6 +47,7 @@ struct CVarContainer : public athena::io::DNA<athena::Endian::Big> {
} // namespace DNACVAR
class CVarManager;
class ICVarValueReference;
class CVar : protected DNACVAR::CVar {
friend class CVarManager;
Delete _d;
@ -148,6 +148,13 @@ public:
void lock();
void addListener(ListenerFunc func) { m_listeners.push_back(std::move(func)); }
void addVariableReference(ICVarValueReference* v) { m_valueReferences.push_back(v); }
void removeVariableReference(ICVarValueReference* v) {
auto it = std::find(m_valueReferences.begin(), m_valueReferences.end(), v);
if (it != m_valueReferences.end()) {
m_valueReferences.erase(it);
}
}
bool isValidInput(std::string_view input) const;
@ -164,6 +171,7 @@ private:
bool m_unlocked = false;
bool m_wasDeserialized = false;
std::vector<ListenerFunc> m_listeners;
std::vector<ICVarValueReference*> m_valueReferences;
bool safeToModify(EType type) const;
void init(EFlags flags, bool removeColor = true);
};
@ -303,5 +311,43 @@ public:
m_cvar->lock();
}
};
class ICVarValueReference {
protected:
CVar* m_cvar = nullptr;
public:
ICVarValueReference() = default;
explicit ICVarValueReference(CVar* cv) : m_cvar(cv) {
if (m_cvar != nullptr) {
m_cvar->addVariableReference(this);
}
}
virtual ~ICVarValueReference() {
if (m_cvar != nullptr) {
m_cvar->removeVariableReference(this);
}
m_cvar = nullptr;
}
virtual void updateValue() = 0;
};
template <typename T>
class CVarValueReference : public ICVarValueReference {
T* m_valueRef = nullptr;
public:
CVarValueReference() = default;
explicit CVarValueReference(T* t, CVar* cv) : ICVarValueReference(cv) {
m_valueRef = t;
if (m_valueRef && m_cvar) {
m_cvar->toValue(*m_valueRef);
}
}
void updateValue() override {
if (m_valueRef != nullptr && m_cvar->isModified()) {
m_cvar->toValue(*m_valueRef);
}
}
};
} // namespace hecl

View File

@ -36,14 +36,17 @@ extern "C" int rep_closefrom(int lower);
#include <functional>
#include <list>
#include <map>
#include <optional>
#include <regex>
#include <string>
#include "logvisor/logvisor.hpp"
#include "FourCC.hpp"
#include "athena/Global.hpp"
#include "logvisor/logvisor.hpp"
#include "xxhash/xxhash.h"
#include "FourCC.hpp"
#if defined(__has_feature)
#if __has_feature(thread_sanitizer)
#define HECL_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))

View File

@ -449,6 +449,9 @@ void CVar::lock() {
void CVar::dispatch() {
for (const ListenerFunc& listen : m_listeners)
listen(this);
for (auto* ref : m_valueReferences) {
ref->updateValue();
}
}
bool isReal(std::string_view v) {