Skip to content

Commit acedf10

Browse files
Revert "Merge branch 'all-in-one-vs2022' into all-in-one-vs2022-wpo"
This reverts commit 2a67e0f, reversing changes made to fa94e39.
1 parent ffad5e7 commit acedf10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+401
-262
lines changed

gamedata/scripts/lua_help_ex.script

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,31 @@
385385
function add_attachment(number, string);
386386
function get_attachment(number);
387387
function remove_attachment(number);
388+
389+
// Shader/Textures
390+
function get_shaders(bool)
391+
function set_shader(number, string, string, bool)
392+
393+
get_shaders(hud_mode)
394+
hud_mode is optional and will default to false
395+
returns a table of submesh IDs with subtables containing the shader and texture names of all submeshes of a model, table looks like this for example:
396+
{
397+
1 =
398+
{
399+
texture = "act\act_face_mask_03",
400+
shader = "models\model_pn",
401+
},
402+
2 =
403+
{
404+
texture = "act\act_stalker_cskysun_2",
405+
shader = "models\model_pn",
406+
},
407+
},
408+
409+
set_shader(id, shader, texture, hud_mode) can assign a new shader/texture to the submesh ID
410+
id can be -1 to apply the shader/texture to all submeshes at once
411+
shader/texture can be nil if you only want to apply one of them
412+
hud_mode is optional and will default to false
388413
}
389414

390415
class CArtefact : CGameObject {

src/Include/xrRender/RenderVisual.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ class IKinematicsAnimated;
77
class IParticleCustom;
88
struct vis_data;
99

10+
enum IRenderVisualFlags
11+
{
12+
eIgnoreOptimization = (1 << 0),
13+
eNoShadow = (1 << 1),
14+
};
15+
1016
class IRenderVisual
1117
{
1218
public:
13-
IRenderVisual() { _ignore_optimization = false; }
19+
IRenderVisual() { flags.zero(); }
1420

1521
virtual ~IRenderVisual()
1622
{
@@ -19,15 +25,21 @@ class IRenderVisual
1925
virtual vis_data& _BCL getVisData() = 0;
2026
virtual u32 getType() = 0;
2127

22-
bool _ignore_optimization;
28+
Flags16 flags;
2329

2430
#ifdef DEBUG
2531
virtual shared_str _BCL getDebugName() = 0;
2632
#endif
33+
virtual LPCSTR _BCL getDebugShader() { return nullptr; }
34+
virtual LPCSTR _BCL getDebugTexture() { return nullptr; }
35+
36+
virtual xr_vector<IRenderVisual*>* get_children() { return nullptr; };
2737

38+
virtual void SetShaderTexture(char* shader, LPCSTR texture) {};
2839
virtual void MarkAsHot(bool is_hot) {}; //--DSR-- HeatVision
2940
virtual void MarkAsGlowing(bool is_glowing) {}; //--DSR-- SilencerOverheat
3041

42+
virtual IRenderVisual* _BCL dcast_RenderVisual() { return this; }
3143
virtual IKinematics* _BCL dcast_PKinematics() { return 0; }
3244
virtual IKinematicsAnimated* dcast_PKinematicsAnimated() { return 0; }
3345
virtual IParticleCustom* dcast_ParticleCustom() { return 0; }

src/Layers/xrRender/FBasicVisual.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void dxRender_Visual::Release()
4343
void dxRender_Visual::Load(const char* N, IReader* data, u32)
4444
{
4545
dbg_name = N;
46+
skinning = ::Render->m_skinning;
4647

4748
// header
4849
VERIFY(data);
@@ -67,7 +68,7 @@ void dxRender_Visual::Load(const char* N, IReader* data, u32)
6768
string256 fnT, fnS;
6869
data->r_stringZ(fnT, sizeof(fnT));
6970
data->r_stringZ(fnS, sizeof(fnS));
70-
shader.create(fnS, fnT);
71+
SetShaderTexture(fnS, fnT);
7172
}
7273

7374
// desc
@@ -116,6 +117,32 @@ void dxRender_Visual::MarkAsGlowing(bool is_glowing)
116117
}
117118
//--DSR-- SilencerOverheat_end
118119

120+
void dxRender_Visual::SetShaderTexture(char* s_shader, LPCSTR s_texture)
121+
{
122+
if (s_shader && strlen(s_shader))
123+
{
124+
char* no_shadow = strstr(s_shader, "$no_shadows");
125+
126+
if (no_shadow)
127+
{
128+
flags.set(IRenderVisualFlags::eNoShadow, TRUE);
129+
*no_shadow = 0;
130+
}
131+
else
132+
flags.set(IRenderVisualFlags::eNoShadow, FALSE);
133+
134+
dbg_shader = s_shader;
135+
}
136+
137+
if (s_texture && strlen(s_texture))
138+
{
139+
dbg_texture = s_texture;
140+
}
141+
142+
::Render->m_skinning = skinning;
143+
shader.create(*dbg_shader, *dbg_texture);
144+
}
145+
119146
#define PCOPY(a) a = pFrom->a
120147

121148
void dxRender_Visual::Copy(dxRender_Visual* pFrom)
@@ -126,5 +153,9 @@ void dxRender_Visual::Copy(dxRender_Visual* pFrom)
126153
#ifdef _EDITOR
127154
PCOPY(desc);
128155
#endif
156+
PCOPY(flags);
129157
PCOPY(dbg_name);
158+
PCOPY(dbg_shader);
159+
PCOPY(dbg_texture);
160+
PCOPY(skinning);
130161
}

src/Layers/xrRender/FBasicVisual.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,17 @@ class ECORE_API dxRender_Visual : public IRenderVisual
4949
ogf_desc desc ;
5050
#endif
5151
shared_str dbg_name ;
52+
shared_str dbg_shader ;
53+
shared_str dbg_texture ;
5254
virtual shared_str _BCL getDebugName() { return dbg_name; }
55+
virtual LPCSTR _BCL getDebugShader() { return *dbg_shader; }
56+
virtual LPCSTR _BCL getDebugTexture() { return *dbg_texture; }
5357
public:
5458
// Common data for rendering
5559
u32 Type; // visual's type
5660
vis_data vis; // visibility-data
5761
ref_shader shader; // pipe state, shared
62+
s32 skinning;
5863

5964
virtual void Render(float LOD)
6065
{
@@ -75,6 +80,8 @@ class ECORE_API dxRender_Visual : public IRenderVisual
7580
// virtual CKinematicsAnimated*dcast_PKinematicsAnimated () { return 0; }
7681
// virtual IParticleCustom* dcast_ParticleCustom () { return 0; }
7782

83+
virtual void SetShaderTexture(char* shader, LPCSTR texture);
84+
7885
virtual vis_data& _BCL getVisData() { return vis; }
7986
virtual u32 getType() { return Type; }
8087

src/Layers/xrRender/FHierrarhyVisual.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void FHierrarhyVisual::Release()
3737
if (!bDontDelete)
3838
{
3939
for (u32 i = 0; i < children.size(); i++)
40-
children[i]->Release();
40+
((dxRender_Visual*)children[i])->Release();
4141
}
4242
}
4343

@@ -55,7 +55,7 @@ void FHierrarhyVisual::Load(const char* N, IReader* data, u32 dwFlags)
5555
THROW;
5656
#else
5757
u32 ID = data->r_u32();
58-
children[i] = (dxRender_Visual*)::Render->getVisual(ID);
58+
children[i] = ::Render->getVisual(ID);
5959
#endif
6060
}
6161
bDontDelete = TRUE;
@@ -75,7 +75,7 @@ void FHierrarhyVisual::Load(const char* N, IReader* data, u32 dwFlags)
7575
xr_strcpy(short_name, N);
7676
if (strext(short_name)) *strext(short_name) = 0;
7777
strconcat(sizeof(name_load), name_load, short_name, ":", itoa(count, num, 10));
78-
children.push_back((dxRender_Visual*)::Render->model_CreateChild(name_load, O));
78+
children.push_back(::Render->model_CreateChild(name_load, O));
7979
O->close();
8080
O = OBJ->open_chunk(count);
8181
}
@@ -109,7 +109,7 @@ void FHierrarhyVisual::Copy(dxRender_Visual* pSrc)
109109
children.reserve(pFrom->children.size());
110110
for (u32 i = 0; i < pFrom->children.size(); i++)
111111
{
112-
dxRender_Visual* p = (dxRender_Visual*)::Render->model_Duplicate(pFrom->children[i]);
112+
IRenderVisual* p = ::Render->model_Duplicate(pFrom->children[i]);
113113
children.push_back(p);
114114
}
115115
bDontDelete = FALSE;

src/Layers/xrRender/FHierrarhyVisual.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class FHierrarhyVisual : public dxRender_Visual
1313
{
1414
public:
15-
xr_vector<dxRender_Visual*> children;
15+
xr_vector<IRenderVisual*> children;
1616
BOOL bDontDelete;
1717
public:
1818
FHierrarhyVisual();
@@ -25,6 +25,8 @@ class FHierrarhyVisual : public dxRender_Visual
2525
//--DSR-- HeatVision_start
2626
virtual void MarkAsHot(bool is_hot);
2727
//--DSR-- HeatVision_end
28+
29+
virtual xr_vector<IRenderVisual*>* get_children() { return &children; };
2830
};
2931

3032
#endif //FHierrarhyVisualH

src/Layers/xrRender/ModelPool.cpp

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ void CModelPool::Instance_Register(LPCSTR N, dxRender_Visual* V)
171171

172172
void CModelPool::Destroy()
173173
{
174-
// Pool
175-
Pool.clear();
176-
177174
// Registry
178175
while (!Registry.empty())
179176
{
@@ -239,39 +236,22 @@ dxRender_Visual* CModelPool::Create(const char* name, IReader* data)
239236
xr_strcpy(low_name, name);
240237
strlwr(low_name);
241238
if (strext(low_name)) *strext(low_name) = 0;
242-
// Msg ("-CREATE %s",low_name);
243-
244-
// 0. Search POOL
245-
POOL_IT it = Pool.find(low_name);
246-
if (it != Pool.end())
239+
240+
// 1. Search for already loaded model (reference, base model)
241+
dxRender_Visual* Base = Instance_Find(low_name);
242+
if (0 == Base)
247243
{
248-
// 1. Instance found
249-
dxRender_Visual* Model = it->second;
250-
Model->Spawn();
251-
Pool.erase(it);
252-
return Model;
244+
// 2. If not found
245+
bAllowChildrenDuplicate = FALSE;
246+
if (data) Base = Instance_Load(low_name, data, TRUE);
247+
else Base = Instance_Load(low_name, TRUE);
248+
bAllowChildrenDuplicate = TRUE;
253249
}
254-
else
255-
{
256-
// 1. Search for already loaded model (reference, base model)
257-
dxRender_Visual* Base = Instance_Find(low_name);
258250

259-
if (0 == Base)
260-
{
261-
// 2. If not found
262-
bAllowChildrenDuplicate = FALSE;
263-
if (data) Base = Instance_Load(low_name, data,TRUE);
264-
else Base = Instance_Load(low_name,TRUE);
265-
bAllowChildrenDuplicate = TRUE;
266-
#ifdef _EDITOR
267-
if (!Base) return 0;
268-
#endif
269-
}
270-
// 3. If found - return (cloned) reference
271-
dxRender_Visual* Model = Instance_Duplicate(Base);
272-
Registry.insert(mk_pair(Model, low_name));
273-
return Model;
274-
}
251+
// 3. If found - return (cloned) reference
252+
dxRender_Visual* Model = Instance_Duplicate(Base);
253+
Registry.insert(mk_pair(Model, low_name));
254+
return Model;
275255
}
276256

277257
dxRender_Visual* CModelPool::CreateChild(LPCSTR name, IReader* data)
@@ -302,25 +282,7 @@ void CModelPool::DeleteInternal(dxRender_Visual* & V, BOOL bDiscard)
302282
VERIFY(!g_bRendering);
303283
if (!V) return;
304284
V->Depart();
305-
if (bDiscard || bForceDiscard)
306-
{
307-
Discard(V, TRUE);
308-
}
309-
else
310-
{
311-
//
312-
REGISTRY_IT it = Registry.find(V);
313-
if (it != Registry.end())
314-
{
315-
// Registry entry found - move it to pool
316-
Pool.insert(mk_pair(it->second, V));
317-
}
318-
else
319-
{
320-
// Registry entry not-found - just special type of visual / particles / etc.
321-
xr_delete(V);
322-
}
323-
}
285+
Discard(V, bDiscard || bForceDiscard);
324286
V = NULL;
325287
}
326288

@@ -329,20 +291,18 @@ void CModelPool::Delete(dxRender_Visual* & V, BOOL bDiscard)
329291
if (NULL == V) return;
330292
if (g_bRendering)
331293
{
332-
VERIFY(!bDiscard);
333-
ModelsToDelete.push_back(V);
294+
ModelsToDelete.insert(mk_pair(V, !!bDiscard));
334295
}
335296
else
336297
{
337298
DeleteInternal(V, bDiscard);
338299
}
339-
V = NULL;
340300
}
341301

342302
void CModelPool::DeleteQueue()
343303
{
344-
for (u32 it = 0; it < ModelsToDelete.size(); it++)
345-
DeleteInternal(ModelsToDelete[it]);
304+
for (xr_map<dxRender_Visual*, bool>::iterator it = ModelsToDelete.begin(); it != ModelsToDelete.end(); it++)
305+
DeleteInternal((dxRender_Visual*)it->first, it->second);
346306
ModelsToDelete.clear();
347307
}
348308

@@ -352,8 +312,6 @@ void CModelPool::Discard(dxRender_Visual* & V, BOOL b_complete)
352312
REGISTRY_IT it = Registry.find(V);
353313
if (it != Registry.end())
354314
{
355-
// Pool - OK
356-
357315
// Base
358316
const shared_str& name = it->second;
359317
xr_vector<ModelDef>::iterator I = Models.begin();
@@ -387,7 +345,6 @@ void CModelPool::Discard(dxRender_Visual* & V, BOOL b_complete)
387345
}
388346
// Registry
389347
xr_delete(V);
390-
//. xr_free (name);
391348
Registry.erase(it);
392349
}
393350
else
@@ -420,17 +377,6 @@ void CModelPool::Prefetch_One(LPCSTR N)
420377
Delete(V,FALSE);
421378
}
422379

423-
void CModelPool::ClearPool(BOOL b_complete)
424-
{
425-
POOL_IT _I = Pool.begin();
426-
POOL_IT _E = Pool.end();
427-
for (; _I != _E; _I++)
428-
{
429-
Discard(_I->second, b_complete);
430-
}
431-
Pool.clear();
432-
}
433-
434380
dxRender_Visual* CModelPool::CreatePE(PS::CPEDef* source)
435381
{
436382
PS::CParticleEffect* V = (PS::CParticleEffect*)Instance_Create(MT_PARTICLE_EFFECT);
@@ -463,7 +409,6 @@ void CModelPool::dump()
463409
Msg("--- models: %d, mem usage: %d Kb ", k, sz / 1024);
464410
sz = 0;
465411
k = 0;
466-
int free_cnt = 0;
467412
for (REGISTRY_IT it = Registry.begin(); it != Registry.end(); it++)
468413
{
469414
CKinematics* K = PCKinematics((dxRender_Visual*)it->first);
@@ -472,12 +417,10 @@ void CModelPool::dump()
472417
{
473418
u32 cur = K->mem_usage(true);
474419
sz += cur;
475-
bool b_free = (Pool.find(it->second) != Pool.end());
476-
if (b_free) ++free_cnt;
477-
Msg("#%3d: [%s] [%5d Kb] - %s", k++, (b_free) ? "free" : "used", cur / 1024, it->second.c_str());
420+
Msg("#%3d: [%5d Kb] - %s", k++, cur / 1024, it->second.c_str());
478421
}
479422
}
480-
Msg("--- instances: %d, free %d, mem usage: %d Kb ", k, free_cnt, sz / 1024);
423+
Msg("--- instances: %d, mem usage: %d Kb ", k, sz / 1024);
481424
Log("--- model pool --- end.");
482425
}
483426

0 commit comments

Comments
 (0)