forked from themrdemonized/xray-monolith
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFHierrarhyVisual.cpp
More file actions
120 lines (109 loc) · 2.73 KB
/
FHierrarhyVisual.cpp
File metadata and controls
120 lines (109 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// FHierrarhyVisual.cpp: implementation of the FHierrarhyVisual class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#pragma hdrstop
#include "FHierrarhyVisual.h"
#include "../../xrEngine/Fmesh.h"
#ifndef _EDITOR
#include "../../xrEngine/render.h"
#else
#include "../../Include/xrAPI/xrAPI.h"
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
FHierrarhyVisual::FHierrarhyVisual() : dxRender_Visual()
{
bDontDelete = FALSE;
}
FHierrarhyVisual::~FHierrarhyVisual()
{
if (!bDontDelete)
{
for (u32 i = 0; i < children.size(); i++)
::Render->model_Delete((IRenderVisual *&)children[i]);
}
children.clear();
}
void FHierrarhyVisual::Release()
{
if (!bDontDelete)
{
for (u32 i = 0; i < children.size(); i++)
((dxRender_Visual*)children[i])->Release();
}
}
void FHierrarhyVisual::Load(const char* N, IReader* data, u32 dwFlags)
{
dxRender_Visual::Load(N, data, dwFlags);
if (data->find_chunk(OGF_CHILDREN_L))
{
// From Link
u32 cnt = data->r_u32();
children.resize(cnt);
for (u32 i = 0; i < cnt; i++)
{
#ifdef _EDITOR
THROW;
#else
u32 ID = data->r_u32();
children[i] = ::Render->getVisual(ID);
((dxRender_Visual*)children[i])->setID(i + 1);
#endif
}
bDontDelete = TRUE;
}
else
{
if (data->find_chunk(OGF_CHILDREN))
{
// From stream
IReader* OBJ = data->open_chunk(OGF_CHILDREN);
if (OBJ)
{
IReader* O = OBJ->open_chunk(0);
for (int count = 1; O; count++)
{
string_path name_load, short_name, num;
xr_strcpy(short_name, N);
if (strext(short_name)) *strext(short_name) = 0;
strconcat(sizeof(name_load), name_load, short_name, ":", itoa(count, num, 10));
children.push_back(::Render->model_CreateChild(name_load, O));
((dxRender_Visual*)children.back())->setID(count);
O->close();
O = OBJ->open_chunk(count);
}
OBJ->close();
}
bDontDelete = FALSE;
}
else
{
FATAL("Invalid visual");
}
}
}
//--DSR-- HeatVision_start
void FHierrarhyVisual::MarkAsHot(bool is_hot)
{
dxRender_Visual::MarkAsHot(is_hot);
for (u32 i = 0; i < children.size(); i++)
children[i]->MarkAsHot(is_hot);
for (u32 i = 0; i < children_invisible.size(); i++)
children_invisible[i]->MarkAsHot(is_hot);
}
//--DSR-- HeatVision_end
void FHierrarhyVisual::Copy(dxRender_Visual* pSrc)
{
dxRender_Visual::Copy(pSrc);
FHierrarhyVisual* pFrom = (FHierrarhyVisual *)pSrc;
children.clear();
children.reserve(pFrom->children.size());
for (u32 i = 0; i < pFrom->children.size(); i++)
{
IRenderVisual* p = ::Render->model_Duplicate(pFrom->children[i]);
children.push_back(p);
}
bDontDelete = FALSE;
}