summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/FileLoader.cpp37
-rw-r--r--src/core/FileLoader.h1
-rw-r--r--src/core/Game.cpp2
-rw-r--r--src/core/config.h2
4 files changed, 35 insertions, 7 deletions
diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp
index 612851fb..1463b4a5 100644
--- a/src/core/FileLoader.cpp
+++ b/src/core/FileLoader.cpp
@@ -1,4 +1,5 @@
#include "common.h"
+#include <ctype.h>
#include "main.h"
#include "Quaternion.h"
@@ -26,6 +27,9 @@
#include "FileLoader.h"
#include "Streaming.h"
#include "ColStore.h"
+#include "Occlusion.h"
+
+//--MIAMI: file done
char CFileLoader::ms_line[256];
@@ -159,7 +163,6 @@ struct ColHeader
uint32 size;
};
-//--MIAMI: done
void
CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
{
@@ -196,7 +199,6 @@ CFileLoader::LoadCollisionFile(const char *filename, uint8 colSlot)
}
-//--MIAMI: done
bool
CFileLoader::LoadCollisionFileFirstTime(uint8 *buffer, uint32 size, uint8 colSlot)
{
@@ -298,13 +300,15 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
model.numLines = *(int16*)buf;
buf += 4;
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++){
- model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12));
+ //model.lines[i].Set(*(CVector*)buf, *(CVector*)(buf+12));
buf += 24;
}
}else
model.lines = nil;
+ model.numLines = 0;
+ model.lines = nil;
model.numBoxes = *(int16*)buf;
buf += 4;
@@ -323,10 +327,12 @@ CFileLoader::LoadCollisionModel(uint8 *buf, CColModel &model, char *modelname)
model.vertices = (CVector*)RwMalloc(numVertices*sizeof(CVector));
for(i = 0; i < numVertices; i++){
model.vertices[i] = *(CVector*)buf;
+#if 0
if(Abs(model.vertices[i].x) >= 256.0f ||
Abs(model.vertices[i].y) >= 256.0f ||
Abs(model.vertices[i].z) >= 256.0f)
printf("%s:Collision volume too big\n", modelname);
+#endif
buf += 12;
}
}else
@@ -349,7 +355,7 @@ GetNameAndLOD(char *nodename, char *name, int *n)
{
char *underscore = nil;
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;
}
if(underscore){
@@ -1093,7 +1099,7 @@ CFileLoader::LoadScene(const char *filename)
LoadCullZone(line);
break;
case OCCL:
- // TODO(MIAMI): occlusion
+ LoadOcclusionVolume(line);
break;
case PICK:
// unused
@@ -1187,7 +1193,9 @@ CFileLoader::LoadObjectInstance(const char *line)
CColStore::GetBoundingBox(col->level).ContainRect(entity->GetBoundRect());
}else
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{
entity = new CDummyObject;
entity->SetModelIndexNoCreate(id);
@@ -1241,6 +1249,21 @@ CFileLoader::LoadPickup(const char *line)
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
void
CFileLoader::ReloadPaths(const char *filename)
diff --git a/src/core/FileLoader.h b/src/core/FileLoader.h
index 584a2312..077e7bdd 100644
--- a/src/core/FileLoader.h
+++ b/src/core/FileLoader.h
@@ -39,6 +39,7 @@ public:
static void LoadZone(const char *line);
static void LoadCullZone(const char *line);
static void LoadPickup(const char *line);
+ static void LoadOcclusionVolume(const char *line);
static void ReloadPaths(const char *filename);
static void ReloadObjectTypes(const char *filename);
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index b96c8988..3f4a3217 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -84,6 +84,7 @@
#include "World.h"
#include "ZoneCull.h"
#include "Zones.h"
+#include "Occlusion.h"
#include "debugmenu.h"
@@ -272,6 +273,7 @@ bool CGame::Initialise(const char* datFile)
ThePaths.AllocatePathFindInfoMem(4500);
CWeather::Init();
CCullZones::Init();
+ COcclusion::Init();
CCollision::Init();
CTheZones::Init();
CUserDisplay::Init();
diff --git a/src/core/config.h b/src/core/config.h
index 83aca235..5bed9c64 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -66,6 +66,8 @@ enum Config {
// Cull zones
NUMATTRIBZONES = 704,
+ NUMOCCLUSIONVOLUMES = 350,
+
NUMHANDLINGS = 106,
PATHNODESIZE = 4500,