Skip to content

Commit be8a221

Browse files
ShokerStlkXottab-DUTY
authored andcommitted
SWM: Ported xrRender
1 parent a6ccd21 commit be8a221

21 files changed

+276
-12
lines changed

src/Layers/xrRender/Blender_Recorder_StandartBinding.cpp

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define BIND_DECLARE(xf)\
1818
class cl_xform_##xf : public R_constant_setup\
1919
{\
20-
virtual void setup(R_constant* C) {RCache.xforms.set_c_##xf(C); }\
20+
virtual void setup(R_constant* C) { RCache.xforms.set_c_##xf(C); }\
2121
};\
2222
static cl_xform_##xf binder_##xf
2323
BIND_DECLARE(w);
@@ -318,9 +318,53 @@ static class cl_screen_res : public R_constant_setup
318318
}
319319
} binder_screen_res;
320320

321+
// SM_TODO: RCache.hemi заменить на более "логичное" место
322+
static class cl_hud_params : public R_constant_setup //--#SM+#--
323+
{
324+
virtual void setup(R_constant* C) { RCache.set_c(C, g_pGamePersistent->m_pGShaderConstants->hud_params); }
325+
} binder_hud_params;
326+
327+
static class cl_script_params : public R_constant_setup //--#SM+#--
328+
{
329+
virtual void setup(R_constant* C) { RCache.set_c(C, g_pGamePersistent->m_pGShaderConstants->m_script_params); }
330+
} binder_script_params;
331+
332+
static class cl_blend_mode : public R_constant_setup //--#SM+#--
333+
{
334+
virtual void setup(R_constant* C) { RCache.set_c(C, g_pGamePersistent->m_pGShaderConstants->m_blender_mode); }
335+
} binder_blend_mode;
336+
337+
class cl_camo_data : public R_constant_setup //--#SM+#--
338+
{
339+
virtual void setup(R_constant* C) { RCache.hemi.c_camo_data = C; }
340+
};
341+
static cl_camo_data binder_camo_data;
342+
343+
class cl_custom_data : public R_constant_setup //--#SM+#--
344+
{
345+
virtual void setup(R_constant* C) { RCache.hemi.c_custom_data = C; }
346+
};
347+
static cl_custom_data binder_custom_data;
348+
349+
class cl_entity_data : public R_constant_setup //--#SM+#--
350+
{
351+
virtual void setup(R_constant* C) { RCache.hemi.c_entity_data = C; }
352+
};
353+
static cl_entity_data binder_entity_data;
354+
321355
// Standart constant-binding
322356
void CBlender_Compile::SetMapping()
323357
{
358+
// misc
359+
r_Constant("m_hud_params", &binder_hud_params); //--#SM+#--
360+
r_Constant("m_script_params", &binder_script_params); //--#SM+#--
361+
r_Constant("m_blender_mode", &binder_blend_mode); //--#SM+#--
362+
363+
// objects data
364+
r_Constant("m_obj_camo_data", &binder_camo_data); //--#SM+#--
365+
r_Constant("m_obj_custom_data", &binder_custom_data); //--#SM+#--
366+
r_Constant("m_obj_entity_data", &binder_entity_data); //--#SM+#--
367+
324368
// matrices
325369
r_Constant("m_W", &binder_w);
326370
r_Constant("m_invW", &binder_invw);
@@ -374,7 +418,7 @@ void CBlender_Compile::SetMapping()
374418
r_Constant("screen_res", &binder_screen_res);
375419

376420
// detail
377-
//if (bDetail && detail_scaler)
421+
// if (bDetail && detail_scaler)
378422
// Igor: bDetail can be overridden by no_detail_texture option.
379423
// But shader can be deatiled implicitly, so try to set this parameter
380424
// anyway.

src/Layers/xrRender/D3DXRenderBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class D3DXRenderBase : public IRender, public pureFrame
108108
d = counter_D;
109109
}
110110
void clear_Counters() { counter_S = counter_D = 0; }
111+
111112
public:
112113
D3DXRenderBase();
113114

src/Layers/xrRender/DetailManager.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ void bwdithermap(int levels, int magic[16][16])
3232
float N = 255.0f / (levels - 1);
3333

3434
/*
35-
* Expand 4x4 dither pattern to 16x16. 4x4 leaves obvious patterning,
36-
* and doesn't give us full intensity range (only 17 sublevels).
37-
*
38-
* magicfact is (N - 1)/16 so that we get numbers in the matrix from 0 to
39-
* N - 1: mod N gives numbers in 0 to N - 1, don't ever want all
40-
* pixels incremented to the next level (this is reserved for the
41-
* pixel value with mod N == 0 at the next level).
42-
*/
35+
* Expand 4x4 dither pattern to 16x16. 4x4 leaves obvious patterning,
36+
* and doesn't give us full intensity range (only 17 sublevels).
37+
*
38+
* magicfact is (N - 1)/16 so that we get numbers in the matrix from 0 to
39+
* N - 1: mod N gives numbers in 0 to N - 1, don't ever want all
40+
* pixels incremented to the next level (this is reserved for the
41+
* pixel value with mod N == 0 at the next level).
42+
*/
4343

4444
float magicfact = (N - 1) / 16;
4545
for (int i = 0; i < 4; i++)
@@ -139,8 +139,7 @@ CDetailManager::~CDetailManager()
139139
xr_free(cache_level1);
140140
#endif
141141
}
142-
/*
143-
*/
142+
144143
#ifndef _EDITOR
145144

146145
/*
@@ -389,6 +388,7 @@ void CDetailManager::Render()
389388
MT_SYNC();
390389

391390
RImplementation.BasicStats.DetailRender.Begin();
391+
g_pGamePersistent->m_pGShaderConstants->m_blender_mode.w = 1.0f; //--#SM+#-- Флаг начала рендера травы [begin of grass render]
392392

393393
#ifndef _EDITOR
394394
float factor = g_pGamePersistent->Environment().wind_strength_factor;
@@ -404,6 +404,8 @@ void CDetailManager::Render()
404404
else
405405
soft_Render();
406406
RCache.set_CullMode(CULL_CCW);
407+
408+
g_pGamePersistent->m_pGShaderConstants->m_blender_mode.w = 0.0f; //--#SM+#-- Флаг конца рендера травы [end of grass render]
407409
RImplementation.BasicStats.DetailRender.End();
408410
m_frame_rendered = RDEVICE.dwFrame;
409411
}

src/Layers/xrRender/FHierrarhyVisual.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ class FHierrarhyVisual : public dxRender_Visual
2222
virtual void Load(const char* N, IReader* data, u32 dwFlags);
2323
virtual void Copy(dxRender_Visual* pFrom);
2424
virtual void Release();
25+
virtual IRenderVisual* getSubModel(u8 idx) //--#SM+#--
26+
{
27+
if (children.size() > idx)
28+
return children[idx];
29+
return NULL;
30+
}
2531
};
2632

2733
#endif // FHierrarhyVisualH
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#pragma once //--#SM+#--
2+
3+
#include "xrCore/_quaternion.h"
4+
5+
namespace KinematicsABT
6+
{
7+
struct additional_bone_transform // Описывает постоянное смещение для указанной кости --#SM+#--
8+
{
9+
bool m_bRotGlobal; // Use XYZ axis instead of HPB
10+
u16 m_bone_id; // Bone ID
11+
Fmatrix m_transform; // Rotation + Position
12+
13+
additional_bone_transform() : m_bRotGlobal(false), m_bone_id(-1) { m_transform.identity(); }
14+
15+
// Установить поворот кости (статичные оси)
16+
void setRotGlobal(const float _x, const float _y, const float _z)
17+
{
18+
m_bRotGlobal = true;
19+
m_transform.setXYZ(_x, _y, _z);
20+
}
21+
22+
void setRotGlobal(Fvector& vRotOfs)
23+
{
24+
setRotGlobal(vRotOfs.x, vRotOfs.y, vRotOfs.z);
25+
}
26+
27+
// Установить поворот кости (кость крутится вместе с осями)
28+
void setRotLocal(const float _x, const float _y, const float _z)
29+
{
30+
m_bRotGlobal = false;
31+
Fquaternion Q;
32+
Q.rotationYawPitchRoll(_y, _x, _z);
33+
m_transform.rotation(Q);
34+
}
35+
36+
void setRotLocal(Fvector& vRotOfs)
37+
{
38+
setRotLocal(vRotOfs.x, vRotOfs.y, vRotOfs.z);
39+
}
40+
41+
// Установить смещение позиции кости
42+
void setPosOffset(const float _x, const float _y, const float _z)
43+
{
44+
m_transform.translate_over(_x, _y, _z);
45+
}
46+
47+
void setPosOffset(Fvector& vPosOfs)
48+
{
49+
setPosOffset(vPosOfs.x, vPosOfs.y, vPosOfs.z);
50+
}
51+
};
52+
}

src/Layers/xrRender/R_Backend_hemi.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ void R_hemi::unmap()
99
c_pos_faces = nullptr;
1010
c_neg_faces = nullptr;
1111
c_material = nullptr;
12+
c_camo_data = nullptr; //--#SM+#--
13+
c_custom_data = nullptr; //--#SM+#--
14+
c_entity_data = nullptr; //--#SM+#--
1215
}
1316

1417
void R_hemi::set_pos_faces(float posx, float posy, float posz)
@@ -27,3 +30,18 @@ void R_hemi::set_material(float x, float y, float z, float w)
2730
if (c_material)
2831
RCache.set_c(c_material, x, y, z, w);
2932
}
33+
34+
// Обновляем значения в шейдерных константах //--#SM+#-- //SM_TODO Переместить
35+
void R_hemi::c_update(IRenderVisual* pVisual)
36+
{
37+
vis_object_data* _data = pVisual->getVisData().obj_data;
38+
39+
if (c_camo_data)
40+
RCache.set_c(c_camo_data, _data->sh_camo_data);
41+
42+
if (c_custom_data)
43+
RCache.set_c(c_custom_data, _data->sh_custom_data);
44+
45+
if (c_entity_data)
46+
RCache.set_c(c_entity_data, _data->sh_entity_data);
47+
}

src/Layers/xrRender/R_Backend_hemi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
#define r_backend_hemiH
33
#pragma once
44

5+
#include "Include/xrRender/RenderVisual.h" //--#SM+#--
6+
57
class ECORE_API R_hemi
68
{
79
public:
810
R_constant* c_pos_faces;
911
R_constant* c_neg_faces;
1012
R_constant* c_material;
13+
R_constant* c_camo_data; //--#SM+#--
14+
R_constant* c_custom_data; //--#SM+#--
15+
R_constant* c_entity_data; //--#SM+#--
1116

1217
public:
1318
R_hemi();
@@ -19,5 +24,7 @@ class ECORE_API R_hemi
1924
void set_pos_faces(float posx, float posy, float posz);
2025
void set_neg_faces(float negx, float negy, float negz);
2126
void set_material(float x, float y, float z, float w);
27+
28+
void c_update(IRenderVisual* pVisual); //--#SM+#--
2229
};
2330
#endif

src/Layers/xrRender/SkeletonAnimated.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,15 @@ void CKinematicsAnimated::LL_BoneMatrixBuild(CBoneInstance& bi, const Fmatrix* p
920920
#endif
921921
}
922922

923+
// Добавить скриптовое смещение для кости --#SM+#--
924+
void CKinematicsAnimated::LL_AddTransformToBone(KinematicsABT::additional_bone_transform& offset)
925+
{
926+
inherited::LL_AddTransformToBone(offset);
927+
}
928+
929+
// Обнулить скриптовое смещение для конкретной кости или всех сразу (bone_id = BI_NONE) --#SM+#--
930+
void CKinematicsAnimated::LL_ClearAdditionalTransform(u16 bone_id) { inherited::LL_ClearAdditionalTransform(bone_id); }
931+
923932
void CKinematicsAnimated::BuildBoneMatrix(
924933
const CBoneData* bd, CBoneInstance& bi, const Fmatrix* parent, u8 channel_mask /*= (1<<0)*/)
925934
{
@@ -931,6 +940,8 @@ void CKinematicsAnimated::BuildBoneMatrix(
931940

932941
LL_BoneMatrixBuild(bi, parent, keys);
933942

943+
CalculateBonesAdditionalTransforms(bd, bi, parent, channel_mask); //--#SM+#--
944+
934945
/*
935946
if(bi.mTransform.c.y>10000)
936947
{

src/Layers/xrRender/SkeletonAnimated.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class ECORE_API CKinematicsAnimated : public CKinematics, public IKinematicsAnim
6464
const CBoneData* bd, CBoneInstance& bi, const Fmatrix* parent, u8 mask_channel = (1 << 0));
6565

6666
public:
67+
virtual void LL_AddTransformToBone(KinematicsABT::additional_bone_transform& offset); //--#SM+#--
68+
virtual void LL_ClearAdditionalTransform(u16 bone_id = BI_NONE); //--#SM+#--
69+
6770
virtual void OnCalculateBones();
6871

6972
public:

src/Layers/xrRender/SkeletonCustom.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ class CKinematics : public FHierrarhyVisual, public IKinematics
105105
friend class CBoneData;
106106
friend class CSkeletonX;
107107

108+
protected: //--#SM+#--
109+
DEFINE_VECTOR(KinematicsABT::additional_bone_transform, BONE_TRANSFORM_VECTOR, BONE_TRANSFORM_VECTOR_IT);
110+
BONE_TRANSFORM_VECTOR m_bones_offsets;
111+
108112
public:
109113
#ifdef DEBUG
110114
BOOL dbg_single_use_marker;
@@ -118,6 +122,11 @@ class CKinematics : public FHierrarhyVisual, public IKinematics
118122
virtual void BuildBoneMatrix(
119123
const CBoneData* bd, CBoneInstance& bi, const Fmatrix* parent, u8 mask_channel = (1 << 0));
120124
virtual void OnCalculateBones() {}
125+
126+
virtual void CalculateBonesAdditionalTransforms(
127+
const CBoneData* bd, CBoneInstance& bi, const Fmatrix* parent, u8 mask_channel = (1 << 0)); //--#SM+#--
128+
virtual void LL_AddTransformToBone(KinematicsABT::additional_bone_transform& offset); //--#SM+#--
129+
virtual void LL_ClearAdditionalTransform(u16 bone_id = BI_NONE); //--#SM+#--
121130
public:
122131
dxRender_Visual* m_lod;
123132

@@ -276,6 +285,7 @@ class CKinematics : public FHierrarhyVisual, public IKinematics
276285

277286
protected:
278287
shared_str getDebugName() override { return dbg_name; }
288+
279289
public:
280290
#endif
281291

0 commit comments

Comments
 (0)