mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Automatically disable billboards on DynOS models with >6 vertices
This commit is contained in:
parent
7576dfbc7c
commit
e912636633
9 changed files with 26 additions and 18 deletions
|
@ -390,6 +390,7 @@ struct DataNode : NoCopy {
|
||||||
Array<String> mTokens;
|
Array<String> mTokens;
|
||||||
u64 mModelIdentifier = 0;
|
u64 mModelIdentifier = 0;
|
||||||
u64 mLoadIndex = 0;
|
u64 mLoadIndex = 0;
|
||||||
|
u8 mFlags = 0;
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using DataNodes = Array<DataNode<T>*>;
|
using DataNodes = Array<DataNode<T>*>;
|
||||||
|
@ -819,6 +820,7 @@ void DynOS_Col_Generate(const SysPath &aPackFolder, Array<Pair<u64, String>> _Ac
|
||||||
|
|
||||||
DataNode<GeoLayout>* DynOS_Geo_Parse(GfxData* aGfxData, DataNode<GeoLayout>* aNode, bool aDisplayPercent);
|
DataNode<GeoLayout>* DynOS_Geo_Parse(GfxData* aGfxData, DataNode<GeoLayout>* aNode, bool aDisplayPercent);
|
||||||
void DynOS_Geo_Write(FILE *aFile, GfxData *aGfxData, DataNode<GeoLayout> *aNode);
|
void DynOS_Geo_Write(FILE *aFile, GfxData *aGfxData, DataNode<GeoLayout> *aNode);
|
||||||
|
DataNode<GeoLayout>** DynOS_Geo_GetLoading(void);
|
||||||
void DynOS_Geo_Load(FILE *aFile, GfxData *aGfxData);
|
void DynOS_Geo_Load(FILE *aFile, GfxData *aGfxData);
|
||||||
|
|
||||||
DataNode<Gfx>* DynOS_Gfx_Parse(GfxData* aGfxData, DataNode<Gfx>* aNode);
|
DataNode<Gfx>* DynOS_Gfx_Parse(GfxData* aGfxData, DataNode<Gfx>* aNode);
|
||||||
|
@ -873,7 +875,7 @@ void DynOS_Vtx_Load(FILE *aFile, GfxData *aGfxData);
|
||||||
|
|
||||||
void DynOS_Pointer_Lua_Write(FILE* aFile, u32 index, GfxData* aGfxData);
|
void DynOS_Pointer_Lua_Write(FILE* aFile, u32 index, GfxData* aGfxData);
|
||||||
void DynOS_Pointer_Write(FILE* aFile, const void* aPtr, GfxData* aGfxData);
|
void DynOS_Pointer_Write(FILE* aFile, const void* aPtr, GfxData* aGfxData);
|
||||||
void *DynOS_Pointer_Load(FILE *aFile, GfxData *aGfxData, u32 aValue);
|
void *DynOS_Pointer_Load(FILE *aFile, GfxData *aGfxData, u32 aValue, u8* outFlags);
|
||||||
|
|
||||||
void DynOS_GfxDynCmd_Load(FILE *aFile, GfxData *aGfxData);
|
void DynOS_GfxDynCmd_Load(FILE *aFile, GfxData *aGfxData);
|
||||||
|
|
||||||
|
|
|
@ -443,7 +443,7 @@ void DynOS_Geo_Load(FILE *aFile, GfxData *aGfxData) {
|
||||||
_Node->mData = New<GeoLayout>(_Node->mSize);
|
_Node->mData = New<GeoLayout>(_Node->mSize);
|
||||||
for (u32 i = 0; i != _Node->mSize; ++i) {
|
for (u32 i = 0; i != _Node->mSize; ++i) {
|
||||||
u32 _Value = ReadBytes<u32>(aFile);
|
u32 _Value = ReadBytes<u32>(aFile);
|
||||||
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value);
|
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value, &_Node->mFlags);
|
||||||
if (_Ptr) {
|
if (_Ptr) {
|
||||||
_Node->mData[i] = (uintptr_t) _Ptr;
|
_Node->mData[i] = (uintptr_t) _Ptr;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -973,7 +973,7 @@ void DynOS_Gfx_Load(FILE *aFile, GfxData *aGfxData) {
|
||||||
for (u32 i = 0; i != _Node->mSize; ++i) {
|
for (u32 i = 0; i != _Node->mSize; ++i) {
|
||||||
u32 _WordsW0 = ReadBytes<u32>(aFile);
|
u32 _WordsW0 = ReadBytes<u32>(aFile);
|
||||||
u32 _WordsW1 = ReadBytes<u32>(aFile);
|
u32 _WordsW1 = ReadBytes<u32>(aFile);
|
||||||
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _WordsW1);
|
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _WordsW1, &_Node->mFlags);
|
||||||
if (_Ptr) {
|
if (_Ptr) {
|
||||||
_Node->mData[i].words.w0 = (uintptr_t) _WordsW0;
|
_Node->mData[i].words.w0 = (uintptr_t) _WordsW0;
|
||||||
_Node->mData[i].words.w1 = (uintptr_t) _Ptr;
|
_Node->mData[i].words.w1 = (uintptr_t) _Ptr;
|
||||||
|
|
|
@ -1984,7 +1984,7 @@ static DataNode<LevelScript>* DynOS_Lvl_Load(FILE *aFile, GfxData *aGfxData) {
|
||||||
// Read it
|
// Read it
|
||||||
for (u32 i = 0; i != _Node->mSize; ++i) {
|
for (u32 i = 0; i != _Node->mSize; ++i) {
|
||||||
u32 _Value = ReadBytes<u32>(aFile);
|
u32 _Value = ReadBytes<u32>(aFile);
|
||||||
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value);
|
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value, &_Node->mFlags);
|
||||||
if (_Ptr) {
|
if (_Ptr) {
|
||||||
_Node->mData[i] = (uintptr_t) _Ptr;
|
_Node->mData[i] = (uintptr_t) _Ptr;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -84,7 +84,7 @@ DataNode<MovtexQC>* DynOS_MovtexQC_Load(FILE *aFile, GfxData *aGfxData) {
|
||||||
for (u32 i = 0; i != _Node->mSize; ++i) {
|
for (u32 i = 0; i != _Node->mSize; ++i) {
|
||||||
_Node->mData[i].id = ReadBytes<s16>(aFile);
|
_Node->mData[i].id = ReadBytes<s16>(aFile);
|
||||||
u32 _Value = ReadBytes<u32>(aFile);
|
u32 _Value = ReadBytes<u32>(aFile);
|
||||||
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value);
|
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value, &_Node->mFlags);
|
||||||
_Node->mData[i].quadArraySegmented = (Movtex*)_Ptr;
|
_Node->mData[i].quadArraySegmented = (Movtex*)_Ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "behavior_table.h"
|
#include "behavior_table.h"
|
||||||
#include "levels/scripts.h"
|
#include "levels/scripts.h"
|
||||||
|
#include "engine/graph_node.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
|
@ -224,7 +225,7 @@ void DynOS_Pointer_Write(FILE* aFile, const void* aPtr, GfxData* aGfxData) {
|
||||||
// Reading //
|
// Reading //
|
||||||
/////////////
|
/////////////
|
||||||
|
|
||||||
static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 aPtrData) {
|
static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 aPtrData, u8* outFlags) {
|
||||||
|
|
||||||
// Lights
|
// Lights
|
||||||
for (auto& _Node : aGfxData->mLights) {
|
for (auto& _Node : aGfxData->mLights) {
|
||||||
|
@ -285,6 +286,7 @@ static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 a
|
||||||
// Display lists
|
// Display lists
|
||||||
for (auto &_Node : aGfxData->mDisplayLists) {
|
for (auto &_Node : aGfxData->mDisplayLists) {
|
||||||
if (_Node->mName == aPtrName) {
|
if (_Node->mName == aPtrName) {
|
||||||
|
*outFlags |= _Node->mFlags;
|
||||||
return (void *) _Node->mData;
|
return (void *) _Node->mData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,6 +294,7 @@ static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 a
|
||||||
// Geo layouts
|
// Geo layouts
|
||||||
for (auto &_Node : aGfxData->mGeoLayouts) {
|
for (auto &_Node : aGfxData->mGeoLayouts) {
|
||||||
if (_Node->mName == aPtrName) {
|
if (_Node->mName == aPtrName) {
|
||||||
|
*outFlags |= _Node->mFlags;
|
||||||
return (void *) _Node->mData;
|
return (void *) _Node->mData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,6 +302,7 @@ static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 a
|
||||||
// Vertices
|
// Vertices
|
||||||
for (auto &_Node : aGfxData->mVertices) {
|
for (auto &_Node : aGfxData->mVertices) {
|
||||||
if (_Node->mName == aPtrName) {
|
if (_Node->mName == aPtrName) {
|
||||||
|
*outFlags |= _Node->mFlags;
|
||||||
return (void *) (_Node->mData + aPtrData);
|
return (void *) (_Node->mData + aPtrData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +397,7 @@ static void *GetPointerFromData(GfxData *aGfxData, const String &aPtrName, u32 a
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *DynOS_Pointer_Load(FILE *aFile, GfxData *aGfxData, u32 aValue) {
|
void *DynOS_Pointer_Load(FILE *aFile, GfxData *aGfxData, u32 aValue, u8* outFlags) {
|
||||||
|
|
||||||
// LUAV
|
// LUAV
|
||||||
if (aValue == LUA_VAR_CODE) {
|
if (aValue == LUA_VAR_CODE) {
|
||||||
|
@ -418,7 +422,7 @@ void *DynOS_Pointer_Load(FILE *aFile, GfxData *aGfxData, u32 aValue) {
|
||||||
if (aValue == POINTER_CODE) {
|
if (aValue == POINTER_CODE) {
|
||||||
String _PtrName; _PtrName.Read(aFile);
|
String _PtrName; _PtrName.Read(aFile);
|
||||||
u32 _PtrData = ReadBytes<u32>(aFile);
|
u32 _PtrData = ReadBytes<u32>(aFile);
|
||||||
return GetPointerFromData(aGfxData, _PtrName, _PtrData);
|
return GetPointerFromData(aGfxData, _PtrName, _PtrData, outFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not a pointer
|
// Not a pointer
|
||||||
|
|
|
@ -76,7 +76,7 @@ DataNode<TexData*>* DynOS_TexList_Load(FILE *aFile, GfxData *aGfxData) {
|
||||||
_Node->mData = New<TexData*>(_Node->mSize);
|
_Node->mData = New<TexData*>(_Node->mSize);
|
||||||
for (u32 i = 0; i != _Node->mSize; ++i) {
|
for (u32 i = 0; i != _Node->mSize; ++i) {
|
||||||
u32 _Value = ReadBytes<u32>(aFile);
|
u32 _Value = ReadBytes<u32>(aFile);
|
||||||
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value);
|
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value, &_Node->mFlags);
|
||||||
if (_Ptr == NULL) {
|
if (_Ptr == NULL) {
|
||||||
PrintError("Could not read texture in texlist");
|
PrintError("Could not read texture in texlist");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include "dynos.cpp.h"
|
#include "dynos.cpp.h"
|
||||||
|
extern "C" {
|
||||||
|
#include "engine/graph_node.h"
|
||||||
|
}
|
||||||
|
|
||||||
#define F32VTX_SENTINEL_0 0x3346
|
#define F32VTX_SENTINEL_0 0x3346
|
||||||
#define F32VTX_SENTINEL_1 0x5632
|
#define F32VTX_SENTINEL_1 0x5632
|
||||||
|
@ -138,6 +141,10 @@ void DynOS_Vtx_Load(FILE *aFile, GfxData *aGfxData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_Node->mSize > 6) {
|
||||||
|
_Node->mFlags |= GRAPH_EXTRA_FORCE_3D;
|
||||||
|
}
|
||||||
|
|
||||||
// Append
|
// Append
|
||||||
aGfxData->mVertices.Add(_Node);
|
aGfxData->mVertices.Add(_Node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@ static void DynOS_Pack_ActivateActor(s32 aPackIndex, Pair<const char *, GfxData
|
||||||
const char* aActorName = pair.first;
|
const char* aActorName = pair.first;
|
||||||
GfxData* aGfxData = pair.second;
|
GfxData* aGfxData = pair.second;
|
||||||
|
|
||||||
GraphNode* graphNode = (GraphNode *) DynOS_Geo_GetGraphNode((*(aGfxData->mGeoLayouts.end() - 1))->mData, false);
|
auto& geoNode = *(aGfxData->mGeoLayouts.end() - 1);
|
||||||
|
GraphNode* graphNode = (GraphNode *) DynOS_Geo_GetGraphNode(geoNode->mData, false);
|
||||||
if (graphNode == NULL) { return; }
|
if (graphNode == NULL) { return; }
|
||||||
|
|
||||||
const void* georef = DynOS_Builtin_Actor_GetFromName(aActorName);
|
const void* georef = DynOS_Builtin_Actor_GetFromName(aActorName);
|
||||||
|
@ -23,15 +24,9 @@ static void DynOS_Pack_ActivateActor(s32 aPackIndex, Pair<const char *, GfxData
|
||||||
actorGfx.mGraphNode = graphNode;
|
actorGfx.mGraphNode = graphNode;
|
||||||
actorGfx.mPackIndex = aPackIndex;
|
actorGfx.mPackIndex = aPackIndex;
|
||||||
|
|
||||||
// Check if we should disable billboards
|
if (geoNode->mFlags & GRAPH_EXTRA_FORCE_3D) {
|
||||||
// TODO: make this smarter
|
|
||||||
/*u32 vertices = 0;
|
|
||||||
for (auto& vtx : aGfxData->mVertices) {
|
|
||||||
vertices += vtx->mSize;
|
|
||||||
}
|
|
||||||
if (vertices > 6) {
|
|
||||||
actorGfx.mGraphNode->extraFlags |= GRAPH_EXTRA_FORCE_3D;
|
actorGfx.mGraphNode->extraFlags |= GRAPH_EXTRA_FORCE_3D;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
DynOS_Actor_Valid(georef, actorGfx);
|
DynOS_Actor_Valid(georef, actorGfx);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue