1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-14 00:54:05 +02:00

#23 fix rebuild water surfaces after setting changes, fix swap interval for TR1 animated textures

This commit is contained in:
XProger
2018-09-30 06:03:12 +03:00
parent fa44799138
commit 9a49d46005
4 changed files with 30 additions and 13 deletions

View File

@@ -1180,10 +1180,10 @@ namespace TR {
struct { uint16 texture:15, doubleSided:1; };
uint16 value;
} flags;
uint8 colored; // !!! not existing in file
uint8 vCount; // !!! not existing in file
short3 normal; // !!! not existing in file
short3 normal;
uint16 vertices[4];
uint8 water:1, colored:1, vCount:6;
static int cmp(const Face &a, const Face &b) {
int aIndex = a.flags.texture;
@@ -3124,6 +3124,8 @@ namespace TR {
#else
f.colored = false;
#endif
f.water = false;
}
void readRoom(Stream &stream, int roomIndex) {
@@ -3362,6 +3364,7 @@ namespace TR {
f.vertices[2] >>= 2;
f.vertices[3] >>= 2;
f.colored = false;
f.water = false;
}
} else
for (int i = 0; i < d.rCount; i++) readFace(stream, d.faces[idx++], false, false);

View File

@@ -1638,9 +1638,13 @@ struct Level : IGame {
params->time += Core::deltaTime;
animTexTimer += Core::deltaTime;
if (animTexTimer > ANIM_TEX_TIMESTEP) {
float timeStep = ANIM_TEX_TIMESTEP;
if (level.version & TR::VER_TR1)
timeStep *= 0.5f;
if (animTexTimer > timeStep) {
level.shiftAnimTex();
animTexTimer -= ANIM_TEX_TIMESTEP;
animTexTimer -= timeStep;
}
updateEffect();

View File

@@ -206,8 +206,7 @@ struct MeshBuilder {
iCount += (d.rCount * 6 + d.tCount * 3) * DOUBLE_SIDED;
vCount += (d.rCount * 4 + d.tCount * 3);
if (Core::settings.detail.water > Core::Settings::LOW)
roomRemoveWaterSurfaces(r, iCount, vCount);
roomRemoveWaterSurfaces(r, iCount, vCount);
for (int j = 0; j < r.meshesCount; j++) {
TR::Room::Mesh &m = r.meshes[j];
@@ -687,11 +686,18 @@ struct MeshBuilder {
}
void roomRemoveWaterSurfaces(TR::Room &room, int &iCount, int &vCount) {
if (Core::settings.detail.water == Core::Settings::LOW) {
for (int i = 0; i < room.data.fCount; i++)
room.data.faces[i].water = false;
return;
}
room.waterLevel = -1;
for (int i = 0; i < room.data.fCount; i++) {
TR::Face &f = room.data.faces[i];
if (f.flags.value == 0xFFFF) continue;
if (f.water) continue;
TR::Vertex &a = room.data.vertices[f.vertices[0]].vertex;
TR::Vertex &b = room.data.vertices[f.vertices[1]].vertex;
@@ -712,7 +718,7 @@ struct MeshBuilder {
if (isWaterSurface(yt, s.roomAbove, room.flags.water) ||
isWaterSurface(yb, s.roomBelow, room.flags.water)) {
f.flags.value = 0xFFFF; // mark as unused
f.water = true;
room.waterLevel = a.y;
if (f.vCount == 4) {
@@ -767,8 +773,8 @@ struct MeshBuilder {
for (int i = 0; i < room.data.fCount; i++) {
TR::Face &f = room.data.faces[i];
if (f.flags.value != 0xFFFF) continue;
if (!f.water) continue;
Index idx[4];
idx[0] = addUniqueVertex(wVertices, room.data.vertices[f.vertices[0]].vertex);
@@ -905,7 +911,7 @@ struct MeshBuilder {
TR::Face &f = d.faces[j];
TR::ObjectTexture &t = level.objectTextures[f.flags.texture];
if (f.flags.value == 0xFFFF) continue; // skip if marks as unused (removing water planes)
if (f.water) continue;
CHECK_ROOM_NORMAL(f);
@@ -939,7 +945,7 @@ struct MeshBuilder {
TR::Face &f = d.faces[j];
TR::ObjectTexture &t = level.objectTextures[f.flags.texture];
if (f.flags.value == 0xFFFF) continue; // skip if marks as unused (removing water planes)
if (f.water) continue;
if (!(blendMask & getBlendMask(t.attribute)))
continue;

View File

@@ -1646,6 +1646,10 @@ struct Array {
count = 0;
}
void sort() {
::sort(items, count);
}
T& operator[] (int index) {
ASSERT(index >= 0 && index < count);
return items[index];