Skip to content

Commit

Permalink
Merge remote-tracking branch 'intorr/intorr_dev' into xd_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jan 2, 2018
2 parents 9798a17 + d71c70d commit 5fab296
Show file tree
Hide file tree
Showing 61 changed files with 717 additions and 2,575 deletions.
29 changes: 0 additions & 29 deletions src/utils/xrAI/AIMapExport.h

This file was deleted.

181 changes: 0 additions & 181 deletions src/utils/xrAI/ETextureParams.h

This file was deleted.

33 changes: 3 additions & 30 deletions src/utils/xrAI/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,8 @@ extern CThreadManager::ReportProgressFunc ProxyProgress;
#include "xrServerEntities/smart_cast.h"
#endif

// Used in:
// src\xrServerEntities\xrServer_Objects_ALife_Items.cpp
// src\xrServerEntities\xrServer_Objects_ALife_Monsters.cpp
#define READ_IF_EXISTS(ltx, method, section, name, default_value)\
(ltx->line_exist(section, name)) ? ltx->method(section, name) : default_value

#if XRAY_EXCEPTIONS
IC xr_string string2xr_string(LPCSTR s) { return s ? s : ""; }
#define THROW(xpr)\
if (!(xpr))\
{\
throw __FILE__LINE__ "\"" #xpr "\"";\
}
#define THROW2(xpr, msg0)\
if (!(xpr))\
{\
throw *shared_str(\
xr_string(__FILE__LINE__).append(" \"").append(#xpr).append(string2xr_string(msg0)).c_str());\
}
#define THROW3(xpr, msg0, msg1)\
if (!(xpr))\
{\
throw *shared_str(xr_string(__FILE__LINE__)\
.append(" \"")\
.append(#xpr)\
.append(string2xr_string(msg0))\
.append(", ")\
.append(string2xr_string(msg1))\
.c_str());\
}
#else
#define THROW VERIFY
#define THROW2 VERIFY2
#define THROW3 VERIFY3
#endif
5 changes: 0 additions & 5 deletions src/utils/xrAI/compiler.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#include "stdafx.h"
#include "compiler.h"
#include "xrCDB/Intersect.hpp"

CDB::MODEL Level;
CDB::COLLIDER XRC;
Nodes g_nodes;
xr_vector<SCover> g_covers_palette;
Lights g_lights;
SAIParams g_params;
Fbox LevelBB;

void mem_Optimize()
{
Expand Down
20 changes: 4 additions & 16 deletions src/utils/xrAI/compiler.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once

#include "xrCDB/xrCDB.h"
#include "Common/LevelStructure.hpp"
#include "AIMapExport.h"
#include "utils/Shader_xrLC.h"
#include "xrAICore/Navigation/level_graph.h"
#include "editors/LevelEditor/Engine/communicate.h"
#include "Etextureparams.h"
#include "editors/LevelEditor/Edit/ESceneAIMapTools_Export.h"
#include "Layers/xrRender/ETextureParams.h"

// base patch used all the time up to merging
const u32 InvalidNode = (1 << 24) - 1;
Expand Down Expand Up @@ -43,18 +43,10 @@ struct vertex // definition of "patch" or "node"
u32 nForward() { return n2; }
u32 nRight() { return n3; }
u32 nBack() { return n4; }
void PointLF(Fvector& D);
void PointFR(Fvector& D);
void PointRB(Fvector& D);
void PointBL(Fvector& D);
};

using DWORDs = xr_vector<u32>;

#include "xrAICore/Navigation/level_graph.h"

void Compress(CLevelGraph::CVertex& Dest, vertex& Src);

#define LT_DIRECT 0
#define LT_POINT 1
#define LT_SECONDARY 2
Expand Down Expand Up @@ -85,13 +77,9 @@ using Marks = xr_vector<BYTE>;
using Lights = xr_vector<R_Light>;

// data
extern CDB::MODEL Level;
extern Nodes g_nodes;
extern xr_vector<SCover> g_covers_palette;
extern Lights g_lights;
extern SAIParams g_params;
extern CDB::MODEL Level;
extern CDB::COLLIDER XRC;
extern Fbox LevelBB;

struct b_BuildTexture : public b_texture
{
Expand Down
26 changes: 10 additions & 16 deletions src/utils/xrAI/compiler_cover.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include "stdafx.h"
#include "compiler.h"
#include "xrCDB/Intersect.hpp"
#include "utils/xrLCUtil/xrThread.hpp"
#include <mmsystem.h>

#include "xrGame/quadtree.h"
#include "xrGame/cover_point.h"
#include "Common/object_broker.h"
#include "xrCore/_fbox2.h"

Shader_xrLC_LIB* g_shaders_xrlc;
xr_vector<b_material> g_materials;
Expand Down Expand Up @@ -266,10 +264,10 @@ class CoverThread : public CThread
Q.Perform(N);

// main cycle: trace rays and compute counts
for (auto it = Q.q_List.begin(); it != Q.q_List.end(); it++)
for (auto &it : Q.q_List)
{
// calc dir & range
u32 ID = *it;
u32 ID = it;
R_ASSERT(ID < g_nodes.size());
if (N == ID)
continue;
Expand Down Expand Up @@ -516,16 +514,14 @@ void compute_non_covers()

float cumulative_weight = 0.f;
{
COVERS::const_iterator i = nearest.begin();
COVERS::const_iterator e = nearest.end();
for (; i != e; ++i)
for (auto &i : nearest)
{
if (!vertex_in_direction(u32(I - B), (*i)->level_vertex_id()))
if (!vertex_in_direction(u32(I - B), i->level_vertex_id()))
continue;

float weight = 1.f / (*i)->position().distance_to((*I).Pos);
float weight = 1.f / i->position().distance_to((*I).Pos);
cumulative_weight += weight;
cover_pairs.push_back(std::make_pair(weight, *i));
cover_pairs.push_back(std::make_pair(weight, i));
}
}

Expand All @@ -552,20 +548,18 @@ void compute_non_covers()
(*I).low_cover[j] = 0.f;
}

COVER_PAIRS::const_iterator i = cover_pairs.begin();
COVER_PAIRS::const_iterator e = cover_pairs.end();
for (; i != e; ++i)
for (auto &i : cover_pairs)
{
vertex& current = g_nodes[(*i).second->level_vertex_id()];
float factor = (*i).first / cumulative_weight;
vertex& current = g_nodes[i.second->level_vertex_id()];
float factor = i.first / cumulative_weight;
for (int j = 0; j < 4; ++j)
{
(*I).high_cover[j] += factor * current.high_cover[j];
(*I).low_cover[j] += factor * current.low_cover[j];
}
}

for (int i2 = 0; i2 < 4; ++i)
for (int i2 = 0; i2 < 4; ++i2)
{
clamp((*I).high_cover[i2], 0.f, 1.f);
clamp((*I).low_cover[i2], 0.f, 1.f);
Expand Down
Loading

0 comments on commit 5fab296

Please sign in to comment.