mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-24 01:50:00 +00:00
finished CFileLoader; some COcclusion stubs
This commit is contained in:
parent
abd230dcdd
commit
62db8cd9b0
|
@ -1,4 +1,5 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include <ctype.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include "Quaternion.h"
|
#include "Quaternion.h"
|
||||||
|
@ -26,6 +27,9 @@
|
||||||
#include "FileLoader.h"
|
#include "FileLoader.h"
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
#include "ColStore.h"
|
#include "ColStore.h"
|
||||||
|
#include "Occlusion.h"
|
||||||
|
|
||||||
|
//--MIAMI: file done
|
||||||
|
|
||||||
char CFileLoader::ms_line[256];
|
char CFileLoader::ms_line[256];
|
||||||
|
|
||||||
|
@ -159,7 +163,6 @@ struct ColHeader
|
||||||
uint32 size;
|
uint32 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
//--MIAMI: done
|
|
||||||
void
|
void
|
||||||
CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
|
CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
|
||||||
{
|
{
|
||||||
|
@ -196,7 +199,6 @@ CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--MIAMI: done
|
|
||||||
bool
|
bool
|
||||||
CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot)
|
CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot)
|
||||||
{
|
{
|
||||||
|
@ -298,13 +300,15 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
|
||||||
model.numLines = *(int16*)buf;
|
model.numLines = *(int16*)buf;
|
||||||
buf += 4;
|
buf += 4;
|
||||||
if(model.numLines > 0){
|
if(model.numLines > 0){
|
||||||
model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine));
|
//model.lines = (CColLine*)RwMalloc(model.numLines*sizeof(CColLine));
|
||||||
for(i = 0; i < model.numLines; i++){
|
for(i = 0; i < model.numLines; i++){
|
||||||
model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12));
|
//model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12));
|
||||||
buf += 24;
|
buf += 24;
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
model.lines = nil;
|
model.lines = nil;
|
||||||
|
model.numLines = 0;
|
||||||
|
model.lines = nil;
|
||||||
|
|
||||||
model.numBoxes = *(int16*)buf;
|
model.numBoxes = *(int16*)buf;
|
||||||
buf += 4;
|
buf += 4;
|
||||||
|
@ -323,10 +327,12 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
|
||||||
model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
|
model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
|
||||||
for(i = 0; i < numVertices; i++){
|
for(i = 0; i < numVertices; i++){
|
||||||
model.vertices[i] = *(CVector*)buf;
|
model.vertices[i] = *(CVector*)buf;
|
||||||
|
#if 0
|
||||||
if(Abs(model.vertices[i].x) >= 256.0f ||
|
if(Abs(model.vertices[i].x) >= 256.0f ||
|
||||||
Abs(model.vertices[i].y) >= 256.0f ||
|
Abs(model.vertices[i].y) >= 256.0f ||
|
||||||
Abs(model.vertices[i].z) >= 256.0f)
|
Abs(model.vertices[i].z) >= 256.0f)
|
||||||
printf("%s:Collision volume too big\n", modelname);
|
printf("%s:Collision volume too big\n", modelname);
|
||||||
|
#endif
|
||||||
buf += 12;
|
buf += 12;
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
|
@ -349,7 +355,7 @@ GetNameAndLOD(char *nodename, char *name, int *n)
|
||||||
{
|
{
|
||||||
char *underscore = nil;
|
char *underscore = nil;
|
||||||
for(char *s = nodename; *s != '\0'; s++){
|
for(char *s = nodename; *s != '\0'; s++){
|
||||||
if(s[0] == '_' && (s[1] == 'l' || s[1] == 'L'))
|
if(s[0] == '_' && (s[1] == 'l' || s[1] == 'L') && isdigit(s[2]))
|
||||||
underscore = s;
|
underscore = s;
|
||||||
}
|
}
|
||||||
if(underscore){
|
if(underscore){
|
||||||
|
@ -1093,7 +1099,7 @@ CFileLoader::LoadScene(const char *filename)
|
||||||
LoadCullZone(line);
|
LoadCullZone(line);
|
||||||
break;
|
break;
|
||||||
case OCCL:
|
case OCCL:
|
||||||
// TODO(MIAMI): occlusion
|
LoadOcclusionVolume(line);
|
||||||
break;
|
break;
|
||||||
case PICK:
|
case PICK:
|
||||||
// unused
|
// unused
|
||||||
|
@ -1187,7 +1193,9 @@ CFileLoader::LoadObjectInstance(const char *line)
|
||||||
CColStore::GetBoundingBox(col->level).ContainRect(entity->GetBoundRect());
|
CColStore::GetBoundingBox(col->level).ContainRect(entity->GetBoundRect());
|
||||||
}else
|
}else
|
||||||
entity->bUsesCollision = false;
|
entity->bUsesCollision = false;
|
||||||
// TODO(MIAMI): set some flag here if col min is below 6
|
|
||||||
|
if(entity->GetPosition().z + col->boundingBox.min.z < 6.0f)
|
||||||
|
entity->bUnderwater = true;
|
||||||
}else{
|
}else{
|
||||||
entity = new CDummyObject;
|
entity = new CDummyObject;
|
||||||
entity->SetModelIndexNoCreate(id);
|
entity->SetModelIndexNoCreate(id);
|
||||||
|
@ -1241,6 +1249,21 @@ CFileLoader::LoadPickup(const char *line)
|
||||||
sscanf(line, "%d %f %f %f", &id, &x, &y, &z);
|
sscanf(line, "%d %f %f %f", &id, &x, &y, &z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CFileLoader::LoadOcclusionVolume(const char *line)
|
||||||
|
{
|
||||||
|
float x, y, z;
|
||||||
|
float width, length, height;
|
||||||
|
float angle;
|
||||||
|
|
||||||
|
sscanf(line, "%f %f %f %f %f %f %f",
|
||||||
|
&x, &y, &z,
|
||||||
|
&width, &length, &height,
|
||||||
|
&angle);
|
||||||
|
COcclusion::AddOne(x, y, z, width, length, z + height/2.0f, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--MIAMI: unused
|
//--MIAMI: unused
|
||||||
void
|
void
|
||||||
CFileLoader::ReloadPaths(const char *filename)
|
CFileLoader::ReloadPaths(const char *filename)
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
static void LoadZone(const char *line);
|
static void LoadZone(const char *line);
|
||||||
static void LoadCullZone(const char *line);
|
static void LoadCullZone(const char *line);
|
||||||
static void LoadPickup(const char *line);
|
static void LoadPickup(const char *line);
|
||||||
|
static void LoadOcclusionVolume(const char *line);
|
||||||
|
|
||||||
static void ReloadPaths(const char *filename);
|
static void ReloadPaths(const char *filename);
|
||||||
static void ReloadObjectTypes(const char *filename);
|
static void ReloadObjectTypes(const char *filename);
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "ZoneCull.h"
|
#include "ZoneCull.h"
|
||||||
#include "Zones.h"
|
#include "Zones.h"
|
||||||
|
#include "Occlusion.h"
|
||||||
#include "debugmenu.h"
|
#include "debugmenu.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,6 +273,7 @@ bool CGame::Initialise(const char* datFile)
|
||||||
ThePaths.AllocatePathFindInfoMem(4500);
|
ThePaths.AllocatePathFindInfoMem(4500);
|
||||||
CWeather::Init();
|
CWeather::Init();
|
||||||
CCullZones::Init();
|
CCullZones::Init();
|
||||||
|
COcclusion::Init();
|
||||||
CCollision::Init();
|
CCollision::Init();
|
||||||
CTheZones::Init();
|
CTheZones::Init();
|
||||||
CUserDisplay::Init();
|
CUserDisplay::Init();
|
||||||
|
|
|
@ -66,6 +66,8 @@ enum Config {
|
||||||
// Cull zones
|
// Cull zones
|
||||||
NUMATTRIBZONES = 704,
|
NUMATTRIBZONES = 704,
|
||||||
|
|
||||||
|
NUMOCCLUSIONVOLUMES = 350,
|
||||||
|
|
||||||
NUMHANDLINGS = 106,
|
NUMHANDLINGS = 106,
|
||||||
|
|
||||||
PATHNODESIZE = 4500,
|
PATHNODESIZE = 4500,
|
||||||
|
|
|
@ -2,6 +2,42 @@
|
||||||
|
|
||||||
#include "Occlusion.h"
|
#include "Occlusion.h"
|
||||||
|
|
||||||
|
int32 COcclusion::NumOccludersOnMap;
|
||||||
|
int16 COcclusion::FarAwayList;
|
||||||
|
int16 COcclusion::NearbyList;
|
||||||
|
int16 COcclusion::ListWalkThroughFA;
|
||||||
|
int16 COcclusion::PreviousListWalkThroughFA;
|
||||||
|
COccluder COcclusion::aOccluders[NUMOCCLUSIONVOLUMES];
|
||||||
|
|
||||||
|
void
|
||||||
|
COcclusion::Init(void)
|
||||||
|
{
|
||||||
|
NumOccludersOnMap = 0;
|
||||||
|
FarAwayList = -1;
|
||||||
|
NearbyList = -1;
|
||||||
|
ListWalkThroughFA = -1;
|
||||||
|
PreviousListWalkThroughFA = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
COcclusion::AddOne(float x, float y, float z, float width, float length, float height, float angle)
|
||||||
|
{
|
||||||
|
if(NumOccludersOnMap >= NUMOCCLUSIONVOLUMES)
|
||||||
|
return;
|
||||||
|
|
||||||
|
aOccluders[NumOccludersOnMap].x = x;
|
||||||
|
aOccluders[NumOccludersOnMap].y = y;
|
||||||
|
aOccluders[NumOccludersOnMap].z = z;
|
||||||
|
aOccluders[NumOccludersOnMap].width = width;
|
||||||
|
aOccluders[NumOccludersOnMap].length = length;
|
||||||
|
aOccluders[NumOccludersOnMap].height = height;
|
||||||
|
while(angle < 0.0f) angle += 360.0f;
|
||||||
|
while(angle > 360.0f) angle -= 360.0f;
|
||||||
|
aOccluders[NumOccludersOnMap].angle = angle * UINT16_MAX/360.0f;
|
||||||
|
aOccluders[NumOccludersOnMap].listIndex = FarAwayList;
|
||||||
|
FarAwayList = NumOccludersOnMap++;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
COcclusion::ProcessBeforeRendering(void)
|
COcclusion::ProcessBeforeRendering(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,26 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
class COccluder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int16 width, length, height;
|
||||||
|
int16 x, y, z;
|
||||||
|
uint16 angle;
|
||||||
|
int16 listIndex;
|
||||||
|
};
|
||||||
|
|
||||||
class COcclusion
|
class COcclusion
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static int32 NumOccludersOnMap;
|
||||||
|
static int16 FarAwayList;
|
||||||
|
static int16 NearbyList;
|
||||||
|
static int16 ListWalkThroughFA;
|
||||||
|
static int16 PreviousListWalkThroughFA;
|
||||||
|
|
||||||
|
static COccluder aOccluders[NUMOCCLUSIONVOLUMES];
|
||||||
|
|
||||||
|
static void Init(void);
|
||||||
|
static void AddOne(float x, float y, float z, float width, float length, float height, float angle);
|
||||||
static void ProcessBeforeRendering(void);
|
static void ProcessBeforeRendering(void);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue