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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// A class representing a subselection of something like a mesh
//
//=============================================================================
#ifndef DMECOMPONENT_H
#define DMECOMPONENT_H
#ifdef _WIN32
#pragma once
#endif
#include "datamodel/dmelement.h"
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
class CDmeComponent : public CDmElement
{
DEFINE_ELEMENT( CDmeComponent, CDmElement );
public:
enum Component_t
{
COMP_INVALID = -1,
COMP_VTX,
COMP_FACE,
STANDARD_COMP_COUNT
};
// resolve internal data from changed attributes
virtual void Resolve();
// What type of component is this
Component_t Type() const;
// How many pieces are in this component
virtual int Count() const;
// Are there no pieces in this component
bool IsEmpty() const;
// Are all possible pieces in this component
bool IsComplete() const;
// Is this an equivalent component to another component
virtual bool IsEqual( const CDmeComponent *pRhs ) const;
// Reset to an empty selection
virtual void Clear();
protected:
CDmaVar< int > m_Type;
CDmaVar< bool > m_bComplete;
};
//-----------------------------------------------------------------------------
// The default type is invalid
//-----------------------------------------------------------------------------
inline CDmeComponent::Component_t CDmeComponent::Type() const
{
const int type( m_Type.Get() );
if ( type < 0 || type >= STANDARD_COMP_COUNT )
return COMP_INVALID;
return static_cast< Component_t >( type );
}
//-----------------------------------------------------------------------------
// Are there no pieces in this component
//-----------------------------------------------------------------------------
inline int CDmeComponent::Count() const
{
Assert( 0 );
return 0;
}
//-----------------------------------------------------------------------------
// Are there no pieces in this component
//-----------------------------------------------------------------------------
inline bool CDmeComponent::IsEmpty() const
{
return Count() == 0;
}
//-----------------------------------------------------------------------------
// Are all possible pieces in this component
//-----------------------------------------------------------------------------
inline bool CDmeComponent::IsEqual( const CDmeComponent *pRhs ) const
{
return Type() == pRhs->Type() && Count() == pRhs->Count() && IsComplete() == pRhs->IsComplete();
}
//-----------------------------------------------------------------------------
// Are all possible pieces in this component
//-----------------------------------------------------------------------------
inline bool CDmeComponent::IsComplete() const
{
return m_bComplete.Get();
}
//-----------------------------------------------------------------------------
// Reset to an empty selection
//-----------------------------------------------------------------------------
inline void CDmeComponent::Clear()
{
m_bComplete.Set( false );
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
class CDmeSingleIndexedComponent : public CDmeComponent
{
DEFINE_ELEMENT( CDmeSingleIndexedComponent, CDmeComponent );
public:
// resolve internal data from changed attributes
virtual void Resolve();
// From CDmeComponent
virtual int Count() const;
bool SetType( Component_t type );
void AddComponent( int component, float weight = 1.0f );
void AddComponents( const CUtlVector< int > &components );
void AddComponents( const CUtlVector< int > &components, const CUtlVector< float > &weights );
void RemoveComponent( int component );
bool GetComponent( int index, int &component, float &weight ) const;
bool GetWeight( int component, float &weight ) const;
void GetComponents( CUtlVector< int > &components ) const;
void GetComponents( CUtlVector< int > &components, CUtlVector< float > &weights ) const;
void SetComplete( int nComplete );
int GetComplete() const;
bool HasComponent( int component ) const;
virtual void Clear();
void Add( const CDmeSingleIndexedComponent &rhs );
void Add( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Add( *pRhs ); }
void Union( const CDmeSingleIndexedComponent &rhs ) { Add( rhs ); }
void Union( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Add( *pRhs ); }
CDmeSingleIndexedComponent &operator+=( const CDmeSingleIndexedComponent &rhs ) { Add( rhs ); return *this; }
void Subtract( const CDmeSingleIndexedComponent &rhs );
void Subtract( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Subtract( *pRhs ); }
void Complement( const CDmeSingleIndexedComponent &rhs ) { Subtract( rhs ); }
void Complement( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Subtract( *pRhs ); }
CDmeSingleIndexedComponent &operator-=( const CDmeSingleIndexedComponent &rhs ) { Subtract( rhs ); return *this; }
void Intersection( const CDmeSingleIndexedComponent &rhs );
void Intersection( const CDmeSingleIndexedComponent *pRhs ) { Assert( pRhs ); Intersection( *pRhs ); }
protected:
int BinarySearch( int component ) const;
CDmaVar< int > m_CompleteCount;
CDmaArray< int > m_Components;
CDmaArray< float > m_Weights;
};
#endif // DMECOMPONENT_H
|