Skip to content

Commit

Permalink
Fix some compilation error
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Nov 15, 2024
1 parent d6cf948 commit fccd09d
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 63 deletions.
26 changes: 13 additions & 13 deletions src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2938,7 +2938,7 @@ void Bsp::delete_oob_data(int clipFlags) {
print_log(" Deleted {} entities\n", deletedEnts);
ents = newEnts;

uint8_t* oobFaces = new uint8_t[faceCount];
unsigned char* oobFaces = new unsigned char[faceCount];
memset(oobFaces, 0, faceCount * sizeof(bool));
int oobFaceCount = 0;

Expand Down Expand Up @@ -3039,7 +3039,7 @@ void Bsp::delete_oob_data(int clipFlags) {
}
else {
for (int k = 0; k < leaf.nMarkSurfaces; k++) {
unsigned int faceIdx = marksurfs[leaf.iFirstMarkSurface + k];
int faceIdx = marksurfs[leaf.iFirstMarkSurface + k];

int offset = 0;
for (int j = 0; j < faceIdx; j++) {
Expand Down Expand Up @@ -3264,7 +3264,7 @@ void Bsp::delete_box_data(vec3 clipMins, vec3 clipMaxs) {
print_log(" Deleted {} entities\n", deletedEnts);
ents = newEnts;

uint8_t* oobFaces = new uint8_t[faceCount];
unsigned char* oobFaces = new unsigned char[faceCount];
memset(oobFaces, 0, faceCount * sizeof(bool));
int oobFaceCount = 0;

Expand Down Expand Up @@ -3358,7 +3358,7 @@ void Bsp::delete_box_data(vec3 clipMins, vec3 clipMaxs) {
}
else {
for (int k = 0; k < leaf.nMarkSurfaces; k++) {
unsigned int faceIdx = marksurfs[leaf.iFirstMarkSurface + k];
int faceIdx = marksurfs[leaf.iFirstMarkSurface + k];

int offset = 0;
for (int j = 0; j < faceIdx; j++) {
Expand Down Expand Up @@ -3766,11 +3766,11 @@ bool Bsp::subdivide_face(int faceIdx) {
std::vector<vec3>& cutPoly = polys[k];

newFaces[faceIdx + k] = faces[faceIdx];
newFaces[faceIdx + k].iFirstEdge = surfedgePtr - newSurfEdges;
newFaces[faceIdx + k].iFirstEdge = (int)(surfedgePtr - newSurfEdges);
newFaces[faceIdx + k].nEdges = (int)cutPoly.size();

int vertOffset = vertPtr - newVerts;
int edgeOffset = edgePtr - newEdges;
int vertOffset = (int)(vertPtr - newVerts);
int edgeOffset = (int)(edgePtr - newEdges);

for (int i = 0; i < cutPoly.size(); i++) {
edgePtr->iVertex[0] = vertOffset + i;
Expand Down Expand Up @@ -4062,9 +4062,9 @@ bool Bsp::downscale_texture(int textureId, int newWidth, int newHeight) {
adjust_downscaled_texture_coordinates(textureId, oldWidth, oldHeight);

// shrink texture lump
int removedBytes = palette - newPalette;
int removedBytes = (int)(palette - newPalette);
unsigned char* texEnd = newPalette + 256 * sizeof(COLOR3);
int shiftBytes = (texEnd - textures) + removedBytes;
int shiftBytes = (int)(texEnd - textures) + removedBytes;

memcpy(texEnd, texEnd + removedBytes, bsp_header.lump[LUMP_TEXTURES].nLength - shiftBytes);
for (int k = textureId + 1; k < textureCount; k++) {
Expand Down Expand Up @@ -4193,7 +4193,7 @@ void Bsp::downscale_invalid_textures() {
continue;
}

if (tex.nWidth * tex.nHeight > MAX_TEXTURE_SIZE) {
if ((unsigned int)tex.nWidth * tex.nHeight > MAX_TEXTURE_SIZE) {

int oldWidth = tex.nWidth;
int oldHeight = tex.nHeight;
Expand All @@ -4204,13 +4204,13 @@ void Bsp::downscale_invalid_textures() {

while (newWidth > 16) {
newWidth -= 16;
newHeight = newWidth * ratio;
newHeight = (int)(newWidth * ratio);

if (newHeight % 16 != 0) {
continue;
}

if (newWidth * newHeight <= MAX_TEXTURE_SIZE) {
if ((unsigned int)newWidth * newHeight <= MAX_TEXTURE_SIZE) {
break;
}
}
Expand Down Expand Up @@ -6354,7 +6354,7 @@ bool Bsp::validate()
print_log(PRINT_RED | PRINT_INTENSITY, get_localized_string(LANG_0136), texlen, tex->szName[0] != '\0' ? tex->szName : "UNKNOWN_NAME", texOffset, dataOffset);
}
}
else if (tex->nWidth * tex->nHeight > MAX_TEXTURE_SIZE) {
else if ((unsigned int)tex->nWidth * tex->nHeight > MAX_TEXTURE_SIZE) {
print_log("Texture '{}' too large ({}x{})\n", tex->szName, tex->nWidth, tex->nHeight);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/bsp/BspMerger.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ struct MAPBLOCK
float zdelta_neg = other.maxs.z - mins.z;
float zdelta_pos = maxs.z - other.mins.z;

int xdelta = xdelta_neg < xdelta_pos ? ceilf(xdelta_neg + 1.5f) : -ceilf(xdelta_pos + 1.5f);
int ydelta = ydelta_neg < ydelta_pos ? ceilf(ydelta_neg + 1.5f) : -ceilf(ydelta_pos + 1.5f);
int zdelta = zdelta_neg < zdelta_pos ? ceilf(zdelta_neg + 1.5f) : -ceilf(zdelta_pos + 1.5f);
float xdelta = xdelta_neg < xdelta_pos ? ceilf(xdelta_neg + 1.5f) : -ceilf(xdelta_pos + 1.5f);
float ydelta = ydelta_neg < ydelta_pos ? ceilf(ydelta_neg + 1.5f) : -ceilf(ydelta_pos + 1.5f);
float zdelta = zdelta_neg < zdelta_pos ? ceilf(zdelta_neg + 1.5f) : -ceilf(zdelta_pos + 1.5f);

result.moveFixes = vec3(xdelta, ydelta, zdelta);
result.moveFixes2 = vec3(-xdelta, -ydelta, -zdelta);
Expand Down
2 changes: 0 additions & 2 deletions src/bsp/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,6 @@ vec3 Entity::getHullOrigin(Bsp* map) {
int modelIdx = getBspModelIdx();

if (modelIdx != -1) {
BSPMODEL& model = map->models[modelIdx];

vec3 mins, maxs;
map->get_model_vertex_bounds(modelIdx, mins, maxs);
ori += (maxs + mins) * 0.5f;
Expand Down
9 changes: 2 additions & 7 deletions src/editor/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ void Renderer::renderLoop()
Line2D otherEdge(linkPoly.topdownVerts[k], linkPoly.topdownVerts[knext]);

float t0, t1, t2, t3;
float overlapDist = thisEdge.getOverlapRanges(otherEdge, t0, t1, t2, t3);
thisEdge.getOverlapRanges(otherEdge, t0, t1, t2, t3);

vec3 delta1 = poly.verts[inext] - poly.verts[n];
vec3 delta2 = linkPoly.verts[knext] - linkPoly.verts[k];
Expand All @@ -889,7 +889,6 @@ void Renderer::renderLoop()
float stepUnits = 1.0f;
float step = stepUnits / flatLen;
TraceResult tr;
bool isBlocked = true;
for (float f = 0; f < 0.5f; f += step) {
vec3 test1 = mid1 + (delta1 * f) + testOffset;
vec3 test2 = mid2 + (delta2 * f) + testOffset;
Expand All @@ -912,10 +911,6 @@ void Renderer::renderLoop()
drawLine(test3, test4, COLOR4(255, 0, 0, 255));
}
}

//if (isBlocked) {
// continue;
//}
}

glEnable(GL_DEPTH_TEST);
Expand Down Expand Up @@ -2852,7 +2847,7 @@ void Renderer::drawPolygon3D(Polygon3D& poly, COLOR4 color) {
verts[i].c = color;
}

VertexBuffer buffer(g_app->colorShader, verts, poly.verts.size(), GL_TRIANGLE_FAN);
VertexBuffer buffer(g_app->colorShader, verts, (int)poly.verts.size(), GL_TRIANGLE_FAN);
buffer.drawFull();
}

Expand Down
30 changes: 15 additions & 15 deletions src/nav/LeafNavMeshGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@


LeafNavMesh* LeafNavMeshGenerator::generate(Bsp* map) {
float NavMeshGeneratorGenStart = glfwGetTime();
double NavMeshGeneratorGenStart = glfwGetTime();

float createLeavesStart = glfwGetTime();
double createLeavesStart = NavMeshGeneratorGenStart;
std::vector<LeafNode> leaves = getHullLeaves(map, 0, CONTENTS_EMPTY);
print_log("Created {} leaf nodes in {}\n", leaves.size(), glfwGetTime() - createLeavesStart);
print_log("Created {} leaf nodes in {}\n", leaves.size(), (float)(glfwGetTime() - createLeavesStart));

LeafOctree* octree = createLeafOctree(map, leaves, octreeDepth);
LeafNavMesh* navmesh = new LeafNavMesh(leaves, octree);
Expand Down Expand Up @@ -124,7 +124,7 @@ std::vector<LeafNode> LeafNavMeshGenerator::getHullLeaves(Bsp* map, int modelIdx
expandBoundingBox(face.verts[k], leaf.mins, leaf.maxs);
}
}
leaf.center /= leaf.leafFaces.size();
leaf.center /= (float)leaf.leafFaces.size();
leaf.id = (int)emptyLeaves.size();
leaf.origin = leaf.center;

Expand All @@ -150,7 +150,7 @@ void LeafNavMeshGenerator::getOctreeBox(Bsp* map, vec3& min, vec3& max) {
}

LeafOctree* LeafNavMeshGenerator::createLeafOctree(Bsp* map, std::vector<LeafNode>& nodes, int treeDepth) {
float treeStart = glfwGetTime();
double treeStart = glfwGetTime();

vec3 treeMin, treeMax;
getOctreeBox(map, treeMin, treeMax);
Expand All @@ -162,13 +162,13 @@ LeafOctree* LeafNavMeshGenerator::createLeafOctree(Bsp* map, std::vector<LeafNod
}

print_log("Create octree depth {}, size {} -> {} in {}\n", treeDepth,
treeMax.x, treeMax.x / pow(2, treeDepth), (float)glfwGetTime() - treeStart);
treeMax.x, treeMax.x / pow(2, treeDepth), (float)(glfwGetTime() - treeStart));

return octree;
}

void LeafNavMeshGenerator::setLeafOrigins(Bsp* map, LeafNavMesh* mesh) {
float timeStart = glfwGetTime();
double timeStart = glfwGetTime();

for (int i = 0; i < mesh->nodes.size(); i++) {
LeafNode& node = mesh->nodes[i];
Expand Down Expand Up @@ -196,7 +196,7 @@ void LeafNavMeshGenerator::setLeafOrigins(Bsp* map, LeafNavMesh* mesh) {
}
}

print_log("Set leaf origins in {}\n", (float)glfwGetTime() - timeStart);
print_log("Set leaf origins in {}\n", (float)(glfwGetTime() - timeStart));
}

vec3 LeafNavMeshGenerator::getBestPolyOrigin(Bsp* map, Polygon3D& poly, vec3 bias) {
Expand All @@ -215,8 +215,8 @@ vec3 LeafNavMeshGenerator::getBestPolyOrigin(Bsp* map, Polygon3D& poly, vec3 bia
vec3 bestPos = bias;
float pad = 1.0f + EPSILON; // don't choose a point right against a face of the volume

for (int y = poly.localMins.y + pad; y < poly.localMaxs.y - pad; y += step) {
for (int x = poly.localMins.x + pad; x < poly.localMaxs.x - pad; x += step) {
for (float y = poly.localMins.y + pad; y < poly.localMaxs.y - pad; y += step) {
for (float x = poly.localMins.x + pad; x < poly.localMaxs.x - pad; x += step) {
vec3 testPos = poly.unproject(vec2(x, y));
testPos.z += NAV_BOTTOM_EPSILON;

Expand Down Expand Up @@ -250,7 +250,7 @@ vec3 LeafNavMeshGenerator::getBestPolyOrigin(Bsp* map, Polygon3D& poly, vec3 bia

void LeafNavMeshGenerator::linkNavLeaves(Bsp* map, LeafNavMesh* mesh) {
int numLinks = 0;
float linkStart = glfwGetTime();
double linkStart = glfwGetTime();

std::vector<bool> regionLeaves;
regionLeaves.resize(mesh->nodes.size());
Expand All @@ -274,7 +274,7 @@ void LeafNavMeshGenerator::linkNavLeaves(Bsp* map, LeafNavMesh* mesh) {
}
}

print_log("Added {} nav leaf links in {}\n", numLinks, (float)glfwGetTime() - linkStart);
print_log("Added {} nav leaf links in {}\n", numLinks, (float)(glfwGetTime() - linkStart));
}

void LeafNavMeshGenerator::linkEntityLeaves(Bsp* map, LeafNavMesh* mesh) {
Expand Down Expand Up @@ -428,7 +428,7 @@ int LeafNavMeshGenerator::tryFaceLinkLeaves(Bsp* map, LeafNavMesh* mesh, int src
}

void LeafNavMeshGenerator::calcPathCosts(Bsp* bsp, LeafNavMesh* mesh) {
float markStart = glfwGetTime();
double markStart = glfwGetTime();

for (int i = 0; i < mesh->nodes.size(); i++) {
LeafNode& node = mesh->nodes[i];
Expand Down Expand Up @@ -459,13 +459,13 @@ void LeafNavMeshGenerator::calcPathCosts(Bsp* bsp, LeafNavMesh* mesh) {
}
}

print_log("Calculated path costs in {}\n", (float)glfwGetTime() - markStart);
print_log("Calculated path costs in {}\n", (float)(glfwGetTime() - markStart));
}

void LeafNavMeshGenerator::addPathCost(LeafLink& link, Bsp* bsp, vec3 start, vec3 end, bool isDrop) {
TraceResult tr;

int steps = (end - start).length() / 8.0f;
float steps = (end - start).length() / 8.0f;
vec3 delta = end - start;
vec3 dir = delta.normalize();

Expand Down
4 changes: 2 additions & 2 deletions src/nav/NavMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string.h>
#include "GLFW/glfw3.h"

bool NavNode::addLink(int node, int srcEdge, int dstEdge, int zDist, uint8_t _flags) {
bool NavNode::addLink(int node, int srcEdge, int dstEdge, int zDist, unsigned char _flags) {
if (srcEdge < 0 || srcEdge >= MAX_NAV_POLY_VERTS) {
print_log("Error: add link to invalid src edge {}\n", srcEdge);
return false;
Expand Down Expand Up @@ -88,7 +88,7 @@ NavMesh::NavMesh(std::vector<Polygon3D> faces) {
sizeof(NavNode), sizeof(NavLink));
}

bool NavMesh::addLink(int from, int to, int srcEdge, int dstEdge, int zDist, uint8_t flags) {
bool NavMesh::addLink(int from, int to, int srcEdge, int dstEdge, int zDist, unsigned char flags) {
if (from < 0 || to < 0 || from >= MAX_NAV_POLYS || to >= MAX_NAV_POLYS) {
print_log("Error: add link from/to invalid node {} {}\n", from, to);
return false;
Expand Down
10 changes: 5 additions & 5 deletions src/nav/NavMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#define NAV_AUTOCLIMB_HEIGHT 117

struct NavLink {
uint8_t srcEdge : 4; // edge to move from in source poly
uint8_t dstEdge : 4; // edge to move to in target/destination poly
uint8_t flags;
unsigned char srcEdge : 4; // edge to move from in source poly
unsigned char dstEdge : 4; // edge to move to in target/destination poly
unsigned char flags;
int node; // which poly is linked to. -1 = end of links
int zDist; // minimum height difference between the connecting edges
};
Expand All @@ -27,7 +27,7 @@ struct NavNode {
unsigned int id;

// adds a link to node "node" on edge "edge" with height difference "zDist"
bool addLink(int node, int srcEdge, int dstEdge, int zDist, uint8_t flags);
bool addLink(int node, int srcEdge, int dstEdge, int zDist, unsigned char flags);
int numLinks();
};

Expand All @@ -43,7 +43,7 @@ class NavMesh {

NavMesh(std::vector<Polygon3D> polys);

bool addLink(int from, int to, int srcEdge, int dstEdge, int zDist, uint8_t flags);
bool addLink(int from, int to, int srcEdge, int dstEdge, int zDist, unsigned char flags);

void clear();

Expand Down
Loading

0 comments on commit fccd09d

Please sign in to comment.