mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-28 10:41:15 +00:00
Merge branch 'master' into impl/cameralocation-variable
This commit is contained in:
commit
f4c741fcbf
@ -1,10 +1,13 @@
|
||||
#ifndef LEGOANIMACTOR_H
|
||||
#define LEGOANIMACTOR_H
|
||||
|
||||
#include "decomp.h"
|
||||
#include "legopathactor.h"
|
||||
|
||||
class LegoAnimActor : public LegoPathActor {
|
||||
public:
|
||||
LegoAnimActor() {}
|
||||
LegoAnimActor(undefined4);
|
||||
};
|
||||
|
||||
#endif // LEGOANIMACTOR_H
|
||||
|
||||
@ -7,28 +7,36 @@
|
||||
#include "mxstl/stlcompat.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
class LegoActor;
|
||||
class LegoROI;
|
||||
|
||||
#pragma warning(disable : 4237)
|
||||
|
||||
// TODO: generic string comparator?
|
||||
struct LegoUnkSaveDataMapComparator {
|
||||
bool operator()(const char* const& p_a, const char* const& p_b) const { return strcmpi(p_a, p_b) > 0; }
|
||||
struct LegoCharacterComparator {
|
||||
MxBool operator()(const char* const& p_a, const char* const& p_b) const { return strcmpi(p_a, p_b) < 0; }
|
||||
};
|
||||
|
||||
// TODO: pair instead?
|
||||
// SIZE 0x08
|
||||
struct LegoUnkSaveDataMapValue {
|
||||
LegoROI* m_roi; // 0x00
|
||||
MxU32 m_counter; // 0x04
|
||||
struct LegoCharacter {
|
||||
LegoROI* m_roi; // 0x00
|
||||
MxU32 m_refCount; // 0x04
|
||||
|
||||
LegoCharacter(LegoROI* p_roi)
|
||||
{
|
||||
m_roi = p_roi;
|
||||
m_refCount = 1;
|
||||
}
|
||||
|
||||
inline void AddRef() { m_refCount++; }
|
||||
};
|
||||
|
||||
typedef map<char*, LegoUnkSaveDataMapValue*, LegoUnkSaveDataMapComparator> LegoUnkSaveDataMap;
|
||||
typedef map<const char*, LegoCharacter*, LegoCharacterComparator> LegoCharacterMap;
|
||||
|
||||
struct LegoSaveDataEntry3 {
|
||||
char* m_name;
|
||||
void* m_unk0x04;
|
||||
void* m_unk0x08;
|
||||
LegoActor* m_actor;
|
||||
MxS32 m_savePart1;
|
||||
MxS32 m_savePart2;
|
||||
MxU8 m_savePart3;
|
||||
@ -57,7 +65,7 @@ class LegoCharacterManager {
|
||||
|
||||
MxResult WriteSaveData3(LegoStorage* p_storage);
|
||||
MxResult ReadSaveData3(LegoStorage* p_storage);
|
||||
LegoROI* FUN_10083500(const char*, MxBool);
|
||||
LegoROI* GetROI(const char* p_key, MxBool p_createEntity);
|
||||
|
||||
void InitSaveData();
|
||||
static void SetCustomizeAnimFile(const char* p_value);
|
||||
@ -66,6 +74,7 @@ class LegoCharacterManager {
|
||||
void FUN_100832a0();
|
||||
void FUN_10083db0(LegoROI* p_roi);
|
||||
void FUN_10083f10(LegoROI* p_roi);
|
||||
LegoSaveDataEntry3* FUN_10084c60(const char* p_key);
|
||||
MxBool FUN_10084ec0(LegoROI* p_roi);
|
||||
MxU32 FUN_10085140(LegoROI*, MxBool);
|
||||
LegoROI* FUN_10085210(const LegoChar*, LegoChar*, undefined);
|
||||
@ -74,30 +83,38 @@ class LegoCharacterManager {
|
||||
static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; }
|
||||
|
||||
private:
|
||||
LegoROI* CreateROI(const char* p_key);
|
||||
|
||||
static char* g_customizeAnimFile;
|
||||
|
||||
LegoUnkSaveDataMap* m_map; // 0x00
|
||||
LegoCharacterMap* m_characters; // 0x00
|
||||
CustomizeAnimFileVariable* m_customizeAnimFile; // 0x04
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
// FUNCTION: LEGO1 0x10082b90
|
||||
// _Tree<char *,pair<char * const,LegoUnkSaveDataMapValue *>,map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Kfn,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::~_Tree<char *,pair<char * const,LegoUnkSaveDataMapValue *>,map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Kfn,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >
|
||||
// TEMPLATE: LEGO1 0x10082b90
|
||||
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::~_Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >
|
||||
|
||||
// FUNCTION: LEGO1 0x10082c60
|
||||
// _Tree<char *,pair<char * const,LegoUnkSaveDataMapValue *>,map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Kfn,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::iterator::_Inc
|
||||
// TEMPLATE: LEGO1 0x10082c60
|
||||
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::iterator::_Inc
|
||||
|
||||
// FUNCTION: LEGO1 0x10082ca0
|
||||
// _Tree<char *,pair<char * const,LegoUnkSaveDataMapValue *>,map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Kfn,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::erase
|
||||
// TEMPLATE: LEGO1 0x10082ca0
|
||||
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::erase
|
||||
|
||||
// FUNCTION: LEGO1 0x100830f0
|
||||
// _Tree<char *,pair<char * const,LegoUnkSaveDataMapValue *>,map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Kfn,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Erase
|
||||
// TEMPLATE: LEGO1 0x100830f0
|
||||
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Erase
|
||||
|
||||
// FUNCTION: LEGO1 0x10083130
|
||||
// map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::~map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >
|
||||
// TEMPLATE: LEGO1 0x10083130
|
||||
// map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::~map<char *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >
|
||||
|
||||
// TEMPLATE: LEGO1 0x10083840
|
||||
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::iterator::_Dec
|
||||
|
||||
// TEMPLATE: LEGO1 0x10083890
|
||||
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Insert
|
||||
|
||||
// GLOBAL: LEGO1 0x100fc508
|
||||
// _Tree<char *,pair<char * const,LegoUnkSaveDataMapValue *>,map<char *,LegoUnkSaveDataMapValue *,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Kfn,LegoUnkSaveDataMapComparator,allocator<LegoUnkSaveDataMapValue *> >::_Nil
|
||||
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Nil
|
||||
// clang-format on
|
||||
|
||||
#endif // LEGOCHARACTERMANAGER_H
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
#include "legocharactermanager.h"
|
||||
|
||||
#include "legoanimactor.h"
|
||||
#include "legogamestate.h"
|
||||
#include "legovideomanager.h"
|
||||
#include "misc.h"
|
||||
#include "mxmisc.h"
|
||||
#include "roi/legoroi.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
|
||||
DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08)
|
||||
DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108)
|
||||
|
||||
@ -19,7 +23,7 @@ LegoSaveDataEntry3 g_saveData3[66];
|
||||
// FUNCTION: LEGO1 0x10082a20
|
||||
LegoCharacterManager::LegoCharacterManager()
|
||||
{
|
||||
m_map = new LegoUnkSaveDataMap();
|
||||
m_characters = new LegoCharacterMap();
|
||||
InitSaveData();
|
||||
|
||||
m_customizeAnimFile = new CustomizeAnimFileVariable("CUSTOMIZE_ANIM_FILE");
|
||||
@ -96,11 +100,51 @@ MxResult LegoCharacterManager::ReadSaveData3(LegoStorage* p_storage)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10083500
|
||||
LegoROI* LegoCharacterManager::FUN_10083500(const char* p_key, MxBool p_option)
|
||||
// FUNCTION: LEGO1 0x10083500
|
||||
LegoROI* LegoCharacterManager::GetROI(const char* p_key, MxBool p_createEntity)
|
||||
{
|
||||
// TODO
|
||||
// involves an STL map with a _Nil node at 0x100fc508
|
||||
LegoCharacter* character = NULL;
|
||||
LegoCharacterMap::iterator it = m_characters->find(p_key);
|
||||
|
||||
if (it != m_characters->end()) {
|
||||
character = (*it).second;
|
||||
character->AddRef();
|
||||
}
|
||||
|
||||
if (character == NULL) {
|
||||
LegoROI* roi = CreateROI(p_key);
|
||||
roi->SetUnknown0x0c(0);
|
||||
|
||||
if (roi != NULL) {
|
||||
character = new LegoCharacter(roi);
|
||||
char* key = new char[strlen(p_key) + 1];
|
||||
|
||||
if (key != NULL) {
|
||||
strcpy(key, p_key);
|
||||
(*m_characters)[key] = character;
|
||||
VideoManager()->Get3DManager()->Add(*roi);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
VideoManager()->Get3DManager()->Remove(*character->m_roi);
|
||||
VideoManager()->Get3DManager()->Add(*character->m_roi);
|
||||
}
|
||||
|
||||
if (character != NULL) {
|
||||
if (p_createEntity && character->m_roi->GetEntity() == NULL) {
|
||||
// TODO: Match
|
||||
LegoAnimActor* actor = new LegoAnimActor(1);
|
||||
|
||||
actor->SetROI(character->m_roi, FALSE, FALSE);
|
||||
actor->FUN_100114e0(0);
|
||||
actor->SetFlag(LegoActor::c_bit2);
|
||||
FUN_10084c60(p_key)->m_actor = actor;
|
||||
}
|
||||
|
||||
return character->m_roi;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -116,6 +160,12 @@ void LegoCharacterManager::FUN_10083f10(LegoROI* p_roi)
|
||||
// TODO
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10084030
|
||||
LegoROI* LegoCharacterManager::CreateROI(const char* p_key)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10084c00
|
||||
MxBool LegoCharacterManager::FUN_10084c00(const LegoChar*)
|
||||
{
|
||||
@ -123,6 +173,12 @@ MxBool LegoCharacterManager::FUN_10084c00(const LegoChar*)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10084c60
|
||||
LegoSaveDataEntry3* LegoCharacterManager::FUN_10084c60(const char* p_key)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10084ec0
|
||||
MxBool LegoCharacterManager::FUN_10084ec0(LegoROI* p_roi)
|
||||
{
|
||||
|
||||
@ -147,7 +147,7 @@ void LegoGameState::SetActor(MxU8 p_actorId)
|
||||
|
||||
IslePathActor* newActor = new IslePathActor();
|
||||
const char* actorName = LegoActor::GetActorName(m_actorId);
|
||||
LegoROI* roi = CharacterManager()->FUN_10083500(actorName, FALSE);
|
||||
LegoROI* roi = CharacterManager()->GetROI(actorName, FALSE);
|
||||
MxDSAction action;
|
||||
|
||||
action.SetAtomId(*g_isleScript);
|
||||
|
||||
@ -1 +1,9 @@
|
||||
#include "legoanimactor.h"
|
||||
|
||||
// TODO: This might not be the actual constructor of this class,
|
||||
// it only exists temporarily to match other code
|
||||
// STUB: LEGO1 0x1002a500
|
||||
LegoAnimActor::LegoAnimActor(undefined4)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ void LegoAnimPresenter::FUN_100692b0()
|
||||
src = str;
|
||||
}
|
||||
|
||||
roi = CharacterManager()->FUN_10083500(src, TRUE);
|
||||
roi = CharacterManager()->GetROI(src, TRUE);
|
||||
|
||||
if (roi != NULL && str[0] == '*') {
|
||||
roi->SetVisibility(FALSE);
|
||||
|
||||
@ -309,7 +309,7 @@ void LegoModelPresenter::ParseExtra()
|
||||
char* token = strtok(output, g_parseExtraTokens);
|
||||
|
||||
if (m_roi == NULL) {
|
||||
m_roi = CharacterManager()->FUN_10083500(token, FALSE);
|
||||
m_roi = CharacterManager()->GetROI(token, FALSE);
|
||||
m_addedToView = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "mxdirectx/mxstopwatch.h"
|
||||
#include "tgl/d3drm/impl.h"
|
||||
#include "vec.h"
|
||||
#include "viewlod.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(ViewManager, 0x1bc)
|
||||
@ -192,7 +193,7 @@ inline void ViewManager::FUN_100a66f0(ViewROI* p_roi, int p_und)
|
||||
|
||||
if (p_und == -1) {
|
||||
if (p_roi->GetWorldBoundingSphere().Radius() > 0.001F) {
|
||||
float und = FUN_100a6dc0(p_roi->GetWorldBoundingSphere());
|
||||
float und = ProjectedSize(p_roi->GetWorldBoundingSphere());
|
||||
|
||||
if (und < seconds_allowed * g_unk0x1010105c) {
|
||||
if (p_roi->GetUnknown0xe0() == -2) {
|
||||
@ -268,7 +269,7 @@ inline int ViewManager::Unknown()
|
||||
}
|
||||
else {
|
||||
float fVar7 = tan(view_angle / 2.0F);
|
||||
unk0x2c = view_angle * view_angle * 4.0F;
|
||||
view_area_at_one = view_angle * view_angle * 4.0F;
|
||||
|
||||
float fVar1 = front * fVar7;
|
||||
float fVar2 = (width / height) * fVar1;
|
||||
@ -433,11 +434,18 @@ void ViewManager::SetPOVSource(const OrientableROI* point_of_view)
|
||||
}
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100a6dc0
|
||||
float ViewManager::FUN_100a6dc0(const BoundingSphere& p_bounding_sphere)
|
||||
// FUNCTION: LEGO1 0x100a6dc0
|
||||
float ViewManager::ProjectedSize(const BoundingSphere& p_bounding_sphere)
|
||||
{
|
||||
// TODO
|
||||
return 0.0F;
|
||||
// The algorithm projects the radius of bounding sphere onto the perpendicular
|
||||
// plane one unit in front of the camera. That value is simply the ratio of the
|
||||
// radius to the distance from the camera to the sphere center. The projected size
|
||||
// is then the ratio of the area of that projected circle to the view surface area
|
||||
// at Z == 1.0.
|
||||
//
|
||||
float sphere_projected_area = 3.14159265359 * (p_bounding_sphere.Radius() * p_bounding_sphere.Radius());
|
||||
float square_dist_to_sphere = DISTSQRD3(p_bounding_sphere.Center(), pov[3]);
|
||||
return sphere_projected_area / view_area_at_one / square_dist_to_sphere;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x100a6e00
|
||||
|
||||
@ -26,7 +26,7 @@ class ViewManager {
|
||||
void FUN_100a65b0(ViewROI* p_roi, int p_und);
|
||||
void FUN_100a66a0(ViewROI* p_roi);
|
||||
void SetPOVSource(const OrientableROI* point_of_view);
|
||||
float FUN_100a6dc0(const BoundingSphere& p_bounding_sphere);
|
||||
float ProjectedSize(const BoundingSphere& p_bounding_sphere);
|
||||
ViewROI* Pick(Tgl::View* p_view, unsigned long x, unsigned long y);
|
||||
void SetResolution(int width, int height);
|
||||
void SetFrustrum(float fov, float front, float back);
|
||||
@ -50,7 +50,7 @@ class ViewManager {
|
||||
RealtimeView rt_view; // 0x14
|
||||
ROIList visible_rois; // 0x18
|
||||
float unk0x28; // 0x28
|
||||
float unk0x2c; // 0x2c
|
||||
float view_area_at_one; // 0x2c
|
||||
unsigned int flags; // 0x30
|
||||
float width; // 0x34
|
||||
float height; // 0x38
|
||||
|
||||
Loading…
Reference in New Issue
Block a user