forked from GamesDeadLol/GDL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPartCell.cpp
107 lines (86 loc) · 1.91 KB
/
PartCell.cpp
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
#include "StdAfx.h"
#include "PartCell.h"
#include "BSPData.h"
#include "PhysicsPart.h"
CPartCell::CPartCell() : num_shadow_parts(0), shadow_part_list(128)
{
}
CPartCell::~CPartCell()
{
assert(num_shadow_parts == 0);
}
void CPartCell::add_part(CPhysicsPart *part, ClipPlaneList **planes, Frame *frame, unsigned int num_shadow_parts_) // TODO fix this variable name its colliding
{
CShadowPart *newPart;
if (planes)
{
newPart = new CShadowPart(1, planes, frame, part);
}
else
{
newPart = new CShadowPart(NULL, NULL, part);
}
if (num_shadow_parts >= shadow_part_list.alloc_size)
shadow_part_list.grow(shadow_part_list.alloc_size + 100);
shadow_part_list.data[num_shadow_parts++] = newPart;
}
void CPartCell::remove_part(CPhysicsPart *part)
{
for (DWORD i = 0; i < num_shadow_parts; i++)
{
CShadowPart *shadowPart = shadow_part_list.array_data[i];
if (shadowPart->part == part)
{
shadowPart->planes = NULL;
shadowPart->num_planes = 0;
delete shadowPart;
shadow_part_list.array_data[i] = shadow_part_list.array_data[--num_shadow_parts];
if ((num_shadow_parts + 200) < shadow_part_list.alloc_size)
shadow_part_list.shrink(num_shadow_parts + 100);
break;
}
}
}
CShadowPart::CShadowPart(unsigned int nump, ClipPlaneList **planes_, Frame *frame_, CPhysicsPart *part_)
{
num_planes = nump;
planes = planes_;
frame = frame_;
part = part_;
}
CShadowPart::CShadowPart(unsigned int nump, Frame *frame_, CPhysicsPart *part_)
{
part = part_;
frame = frame_;
num_planes = nump;
if (nump)
{
planes = new ClipPlaneList*[nump];
for (DWORD i = 0; i < nump; i++)
planes[i] = NULL;
}
else
{
planes = NULL;
}
}
CShadowPart::~CShadowPart()
{
if (planes)
{
for (DWORD i = 0; i < num_planes; i++)
{
if (planes[i])
{
delete planes[i];
}
}
delete[] planes;
}
}
void CShadowPart::draw(DWORD ClipPlaneIndex)
{
#if PHATSDK_RENDER_AVAILABLE
part->Draw(FALSE);
#endif
}