Skip to content

Commit

Permalink
revision changes:
Browse files Browse the repository at this point in the history
- all `unsigned int` changed to `u32`
- on SoundRender_Emitter.h - var `filled_blocks` reverted to `int` as requested.
- reverted changes to `level_graph_inline.h`
- proposal for `Server_Client_Check()` on `xrServer.cpp`
  • Loading branch information
alsed committed Dec 31, 2024
1 parent cbf6777 commit 91e7e6f
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,13 @@ void R_dsgraph_structure::load(const xr_vector<CSector::level_sector_data_t>& se
Sectors.resize(sectors_count);
Portals.resize(portals_count);

for (unsigned int idx = 0; idx < portals_count; ++idx)
for (u32 idx = 0; idx < portals_count; ++idx)
{
auto* portal = xr_new<CPortal>();
Portals[idx] = portal;
}

for (unsigned int idx = 0; idx < sectors_count; ++idx)
for (u32 idx = 0; idx < sectors_count; ++idx)
{
auto* sector = xr_new<CSector>();

Expand All @@ -690,7 +690,7 @@ void R_dsgraph_structure::load(const xr_vector<CSector::level_sector_data_t>& se
Sectors[idx] = sector;
}

for (unsigned int idx = 0; idx < portals_count; ++idx)
for (u32 idx = 0; idx < portals_count; ++idx)
{
auto* portal = static_cast<CPortal*>(Portals[idx]);

Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRender/r__sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector<CSector*>&
// calc sphere
Fbox BB;
BB.invalidate();
for (unsigned int v = 0; v < vcnt; v++)
for (u32 v = 0; v < vcnt; v++)
BB.modify(V[v]);
BB.getsphere(S.P, S.R);

Expand All @@ -111,7 +111,7 @@ void CPortal::setup(const level_portal_data_t& data, const xr_vector<CSector*>&
N.set(0, 0, 0);

u32 _cnt = 0;
for (unsigned int i = 2; i < vcnt; i++)
for (u32 i = 2; i < vcnt; i++)
{
T.mknormal_non_normalized(poly[0], poly[i - 1], poly[i]);
float m = T.magnitude();
Expand All @@ -136,7 +136,7 @@ void CSector::setup(const level_sector_data_t& data, const xr_vector<CPortal*> &
// Assign portal polygons
const auto num_portals = data.portals_id.size();
m_portals.resize(num_portals);
for (unsigned int idx = 0; idx < num_portals; ++idx)
for (u32 idx = 0; idx < num_portals; ++idx)
{
const auto ID = data.portals_id[idx];
m_portals[idx] = portals[ID];
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender_R2/r2_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void CRender::LoadSectors(IReader* fs)
rmPortals = nullptr;
}

for (unsigned int id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id)
for (u32 id = 0; id < R__NUM_PARALLEL_CONTEXTS; ++id)
{
auto& dsgraph = contexts_pool[id];
dsgraph.reset();
Expand Down
8 changes: 4 additions & 4 deletions src/Layers/xrRender_R2/render_phase_sun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void render_sun::init()
return;

// pre-allocate contexts
for (unsigned int i = 0; i < R__NUM_SUN_CASCADES; ++i)
for (u32 i = 0; i < R__NUM_SUN_CASCADES; ++i)
{
contexts_ids[i] = RImplementation.alloc_context();
VERIFY(contexts_ids[i] != R_dsgraph_structure::INVALID_CONTEXT_ID);
Expand Down Expand Up @@ -114,7 +114,7 @@ void render_sun::calculate()
Fvector3 cull_COP[R__NUM_SUN_CASCADES];
Fmatrix cull_xform[R__NUM_SUN_CASCADES];

for (unsigned int cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind)
for (u32 cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind)
{
cull_planes.clear();

Expand Down Expand Up @@ -378,9 +378,9 @@ void render_sun::flush()

if (RImplementation.o.support_rt_arrays)
{
for (unsigned int i = 0; i < R__NUM_SUN_CASCADES; ++i)
for (u32 cascade_ind = 0; cascade_ind < R__NUM_SUN_CASCADES; ++cascade_ind)
{
accumulate_cascade(i);
accumulate_cascade(cascade_ind);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/xrAICore/Navigation/level_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class XRAICORE_API CLevelGraph
ICF u32 vertex(const CLevelVertex& vertex_r) const;
IC const Fvector vertex_position(const CLevelGraph::CPosition& source_position) const;
IC const Fvector& vertex_position(Fvector& dest_position, const CLevelGraph::CPosition& source_position) const;
IC int calculate_packed_xz(const float x, const float z) const;
IC const CLevelGraph::CPosition& vertex_position(
CLevelGraph::CPosition& dest_position, const Fvector& source_position) const;
IC const CLevelGraph::CPosition vertex_position(const Fvector& position) const;
Expand Down
29 changes: 16 additions & 13 deletions src/xrAICore/Navigation/level_graph_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,19 @@ ICF const Fvector& CLevelGraph::vertex_position(
return (dest_position = vertex_position(source_position));
}

IC int CLevelGraph::calculate_packed_xz(const float x, const float z) const
// XXX: This method is WAY to large to inline.
IC const CLevelGraph::CPosition& CLevelGraph::vertex_position(CPosition& dest_position, const Fvector& source_position) const
{
const auto [box_x, box_y, box_z] = header().box().vMin;
const auto cell_size = header().cell_size();
const int packed_xz = iFloor((x - box_x) / cell_size + .5f) * m_row_length +
iFloor((z - box_z) / cell_size + .5f);

VERIFY(packed_xz < static_cast<int>(NodePosition::MAX_XZ));
return packed_xz;
}
VERIFY(iFloor((source_position.z - box_z) / cell_size + .5f) < (int)m_row_length);

// XXX: This method is WAY too large to inline.
IC const CLevelGraph::CPosition& CLevelGraph::vertex_position(CPosition& dest_position, const Fvector& source_position) const
{
const int packed_xz = calculate_packed_xz(source_position.x, source_position.z);
const int packed_xz = iFloor((source_position.x - box_x) / cell_size + .5f)
* m_row_length + iFloor((source_position.z - box_z) / cell_size + .5f);
VERIFY(packed_xz < NodePosition::MAX_XZ);

int packed_y = iFloor(65535.f * (source_position.y - header().box().vMin.y) / header().factor_y() + EPS_S);
int packed_y = iFloor(65535.f * (source_position.y - box_y) / header().factor_y() + EPS_S);
clamp(packed_y, 0, 65535);

dest_position.xz(u32(packed_xz));
Expand Down Expand Up @@ -199,8 +195,15 @@ IC bool CLevelGraph::inside(const u32 vertex_id, const Fvector& position, const

IC bool CLevelGraph::inside(const u32 vertex_id, const Fvector2& position) const
{
const int packed_xz = calculate_packed_xz(position.x, position.y);
return vertex(vertex_id)->position().xz() == u32(packed_xz);
[[maybe_unused]]
const auto [box_x, box_y, box_z] = header().box().vMin;
const auto cell_size = header().cell_size();

const int packed_xz = iFloor((position.x - box_x) / cell_size + .5f) * m_row_length +
iFloor((position.y - box_z) / cell_size + .5f);
VERIFY(packed_xz < NodePosition::MAX_XZ);
const bool b = vertex(vertex_id)->position().xz() == u32(packed_xz);
return b;
}

IC float CLevelGraph::vertex_plane_y(const CLevelGraph::CLevelVertex& vertex, const float X, const float Z) const
Expand Down
12 changes: 6 additions & 6 deletions src/xrCDB/Frustum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ u32 frustum_aabb_remap[8][6] =
EFC_Visible CFrustum::testSphere(Fvector& c, float r, u32& test_mask) const
{
u32 bit = 1;
for (unsigned int i = 0; i < p_count; i++, bit <<= 1)
for (u32 i = 0; i < p_count; i++, bit <<= 1)
{
if (test_mask & bit)
{
Expand Down Expand Up @@ -162,7 +162,7 @@ EFC_Visible CFrustum::testAABB(const float* mM, u32& test_mask) const
// go for trivial rejection or acceptance using "faster overlap test"
u32 bit = 1;

for (unsigned int i = 0; i < p_count; i++, bit <<= 1)
for (u32 i = 0; i < p_count; i++, bit <<= 1)
{
if (test_mask & bit)
{
Expand All @@ -182,7 +182,7 @@ EFC_Visible CFrustum::testAABB(const float* mM, u32& test_mask) const
EFC_Visible CFrustum::testSAABB(Fvector& c, float r, const float* mM, u32& test_mask) const
{
u32 bit = 1;
for (unsigned int i = 0; i < p_count; i++, bit <<= 1)
for (u32 i = 0; i < p_count; i++, bit <<= 1)
{
if (test_mask & bit)
{
Expand Down Expand Up @@ -213,7 +213,7 @@ EFC_Visible CFrustum::testSAABB(Fvector& c, float r, const float* mM, u32& test_
bool CFrustum::testPolyInside_dirty(Fvector* p, size_t count) const
{
Fvector* e = p + count;
for (unsigned int i = 0; i < p_count; i++)
for (u32 i = 0; i < p_count; i++)
{
const fplane& P = planes[i];
for (Fvector* I = p; I != e; I++)
Expand Down Expand Up @@ -384,7 +384,7 @@ sPoly* CFrustum::ClipPoly(sPoly& S, sPoly& D) const
{
sPoly* src = &D;
sPoly* dest = &S;
for (unsigned int i = 0; i < p_count; i++)
for (u32 i = 0; i < p_count; i++)
{
// cache plane and swap lists
const fplane& P = planes[i];
Expand Down Expand Up @@ -530,7 +530,7 @@ void CFrustum::CreateFromMatrix(Fmatrix& M, u32 mask)
p_count++;
}

for (unsigned int i = 0; i < p_count; i++)
for (u32 i = 0; i < p_count; i++)
{
float denom = 1.0f / planes[i].n.magnitude(); // Get magnitude of Vector
planes[i].n.x *= denom;
Expand Down
6 changes: 3 additions & 3 deletions src/xrCDB/xrCDB_Collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ CollectorPacked::CollectorPacked(const Fbox& bb, int apx_vertices, int apx_faces
flags.reserve(apx_faces);
int _size = (clpMX + 1) * (clpMY + 1) * (clpMZ + 1);
int _average = (apx_vertices / _size) / 2;
for (unsigned int ix = 0; ix < clpMX + 1; ix++)
for (unsigned int iy = 0; iy < clpMY + 1; iy++)
for (unsigned int iz = 0; iz < clpMZ + 1; iz++)
for (u32 ix = 0; ix < clpMX + 1; ix++)
for (u32 iy = 0; iy < clpMY + 1; iy++)
for (u32 iz = 0; iz < clpMZ + 1; iz++)
VM[ix][iy][iz].reserve(_average);
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/xrServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ void xrServer::Server_Client_Check(IClient* CL)
return;
};

if (CL->process_id == static_cast<u32>(GetCurrentProcessId()))
if (static_cast<int>(CL->process_id) == GetCurrentProcessId())
{
CL->flags.bLocal = 1;
SV_Client = (xrClientData*)CL;
Expand Down
2 changes: 1 addition & 1 deletion src/xrSound/SoundRender_Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ CSound* CSoundRender_Core::create(pcstr fName, esound_type sound_type, u32 game_
auto* snd = xr_new<CSound>(handle);

snd->g_type = game_type;
if (game_type == static_cast<int>(sg_SourceType))
if (game_type == sg_SourceType)
snd->g_type = snd->handle->game_type();

snd->s_type = sound_type;
Expand Down
2 changes: 1 addition & 1 deletion src/xrSound/SoundRender_Emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CSoundRender_Emitter final : public CSound_emitter
std::atomic<Task*> prefill_task{};

size_t current_block{};
u32 filled_blocks{};
int filled_blocks{};

void fill_block(void* ptr, u32 size);
void fill_data(void* dest, u32 offset, u32 size) const;
Expand Down

0 comments on commit 91e7e6f

Please sign in to comment.