Skip to content

Commit

Permalink
FPSLIMIT OPTION. FIXED TRANSFORM CLIP-BRUSH.
Browse files Browse the repository at this point in the history
also fixed bad face pick, some fixes in mdl>bsp converter,  etc
  • Loading branch information
UnrealKaraulov committed Feb 4, 2024
1 parent 23fb01c commit e67da48
Show file tree
Hide file tree
Showing 14 changed files with 518 additions and 424 deletions.
3 changes: 2 additions & 1 deletion resources/bspguy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ language=EN
palette=quake_1
save_cam=0
hlrad_path=
hlrad_options={map_path}
hlrad_options={map_path}
fpslimit=100
49 changes: 12 additions & 37 deletions src/bsp/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,49 +388,25 @@ void Bsp::get_model_vertex_bounds(int modelIdx, vec3& mins, vec3& maxs)
maxs = vec3(-FLT_MAX_COORD, -FLT_MAX_COORD, -FLT_MAX_COORD);

BSPMODEL& model = models[modelIdx];
/*auto verts = getModelVerts(modelIdx);
for (auto const& s : verts)
auto rndverts = getModelVerts(modelIdx);
for (auto const& s : rndverts)
{
if (s.pos.x < mins.x)
{
mins.x = s.pos.x;
}
if (s.pos.y < mins.y)
{
mins.y = s.pos.y;
}
if (s.pos.z < mins.z)
{
mins.z = s.pos.z;
}
if (s.pos.x > maxs.x)
{
maxs.x = s.pos.x;
}
if (s.pos.y > maxs.y)
{
maxs.y = s.pos.y;
}
if (s.pos.z > maxs.z)
{
maxs.z = s.pos.z;
}
expandBoundingBox(s.pos, mins, maxs);
}
*/
for (int i = 0; i < model.nFaces; i++)

/*for (int i = 0; i < model.nFaces; i++)
{
BSPFACE32& face = faces[model.iFirstFace + i];
for (int e = 0; e < face.nEdges; e++)
{
int edgeIdx = surfedges[face.iFirstEdge + e];
BSPEDGE32& edge = edges[abs(edgeIdx)];
int vertIdx = edgeIdx >= 0 ? edge.iVertex[1] : edge.iVertex[0];
int vertIdx = edgeIdx < 0 ? edge.iVertex[1] : edge.iVertex[0];
expandBoundingBox(verts[vertIdx], mins, maxs);
}
}
}*/
}

std::vector<TransformVert> Bsp::getModelVerts(int modelIdx)
Expand All @@ -448,7 +424,7 @@ std::vector<TransformVert> Bsp::getModelVerts(int modelIdx)
{
int edgeIdx = surfedges[face.iFirstEdge + e];
BSPEDGE32& edge = edges[abs(edgeIdx)];
int vertIdx = edgeIdx >= 0 ? edge.iVertex[1] : edge.iVertex[0];
int vertIdx = edgeIdx < 0 ? edge.iVertex[1] : edge.iVertex[0];

if (!visited.count(vertIdx))
{
Expand Down Expand Up @@ -558,7 +534,7 @@ bool Bsp::getModelPlaneIntersectVerts(int modelIdx, const std::vector<int>& node
{
int edgeIdx = surfedges[face.iFirstEdge + e];
BSPEDGE32& edge = edges[abs(edgeIdx)];
int vertIdx = edgeIdx >= 0 ? edge.iVertex[1] : edge.iVertex[0];
int vertIdx = edgeIdx < 0 ? edge.iVertex[1] : edge.iVertex[0];

if (verts[vertIdx] != v)
{
Expand Down Expand Up @@ -4857,7 +4833,7 @@ void Bsp::mark_face_structures(int iFace, STRUCTUSAGE* usage)
{
int edgeIdx = surfedges[face.iFirstEdge + e];
BSPEDGE32& edge = edges[abs(edgeIdx)];
int vertIdx = edgeIdx >= 0 ? edge.iVertex[1] : edge.iVertex[0];
int vertIdx = edgeIdx < 0 ? edge.iVertex[1] : edge.iVertex[0];

usage->surfEdges[face.iFirstEdge + e] = true;
usage->edges[abs(edgeIdx)] = true;
Expand Down Expand Up @@ -6676,7 +6652,6 @@ bool Bsp::leaf_add_face(int faceIdx, int leafIdx)
return false;
}


std::vector<int> all_mark_surfaces;
int surface_idx = 0;
for (int i = 0; i < leafCount; i++)
Expand Down Expand Up @@ -7629,7 +7604,7 @@ void Bsp::write_csg_polys(int nodeIdx, FILE* polyfile, int flipPlaneSkip, bool d
{
int edgeIdx = surfedges[e];
BSPEDGE32& edge = edges[abs(edgeIdx)];
vec3 v = edgeIdx >= 0 ? verts[edge.iVertex[1]] : verts[edge.iVertex[0]];
vec3 v = edgeIdx < 0 ? verts[edge.iVertex[1]] : verts[edge.iVertex[0]];
fprintf(polyfile, "%5.8f %5.8f %5.8f\n", v.x, v.y, v.z);
}
}
Expand All @@ -7639,7 +7614,7 @@ void Bsp::write_csg_polys(int nodeIdx, FILE* polyfile, int flipPlaneSkip, bool d
{
int edgeIdx = surfedges[e];
BSPEDGE32& edge = edges[abs(edgeIdx)];
vec3 v = edgeIdx >= 0 ? verts[edge.iVertex[1]] : verts[edge.iVertex[0]];
vec3 v = edgeIdx < 0 ? verts[edge.iVertex[1]] : verts[edge.iVertex[0]];
fprintf(polyfile, "%5.8f %5.8f %5.8f\n", v.x, v.y, v.z);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/bsp/bsptypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BSPEDGE32::BSPEDGE32(unsigned int v1, unsigned int v2)
iVertex[1] = v2;
}

bool BSPPLANE::update_plane(vec3 newNormal, float fdist)
bool BSPPLANE::update_plane(vec3 newNormal, float fdist, bool flip)
{
double fx = abs(newNormal.x);
double fy = abs(newNormal.y);
Expand Down
2 changes: 1 addition & 1 deletion src/bsp/bsptypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct BSPPLANE
int nType;

// returns true if the plane was flipped
bool update_plane(vec3 newNormal, float fdist);
bool update_plane(vec3 newNormal, float fdist, bool flip = true);

BSPPLANE() :vNormal(vec3())
{
Expand Down
2 changes: 1 addition & 1 deletion src/editor/BspRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3099,7 +3099,7 @@ bool BspRenderer::pickModelPoly(vec3 start, const vec3& dir, vec3 offset, int mo
{
int edgeIdx = map->surfedges[e];
BSPEDGE32 edge = map->edges[abs(edgeIdx)];
vec3& v = edgeIdx >= 0 ? map->verts[edge.iVertex[1]] : map->verts[edge.iVertex[0]];
vec3& v = edgeIdx < 0 ? map->verts[edge.iVertex[1]] : map->verts[edge.iVertex[0]];
if (vectest != vec3() && vectest == v)
{
badface = true;
Expand Down
Loading

0 comments on commit e67da48

Please sign in to comment.