2 #include "LodParameter.h"
3 #include <CrySerialization/IArchive.h>
4 #include <CrySerialization/Callback.h>
5 #include <CrySerialization/Decorators/Range.h>
6 #include <CrySerialization/Color.h>
7 #include <CrySerialization/Enum.h>
8 #include <CrySerialization/Decorators/LocalFrame.h>
9 #include "Controls/PropertyItem.h"
10 #include "Util/Variable.h"
11 #include "../panel/GeneratorOptionsPanel.h"
13 using Serialization::Vec3AsColor
;
14 void SLodParameter::Serialize(Serialization::IArchive
& ar
)
18 if (m_TODParamType
== ELodParamType::eColorType
)
20 ar(Vec3AsColor(m_Color
), "color", "^");
21 if (m_CGeneratorOptionsPanel
!= NULL
)
22 m_CGeneratorOptionsPanel
->ParameterChanged(this);
24 else if (m_TODParamType
== ELodParamType::eFloatType
)
26 auto callback
= [&](float v
)
30 if(m_CGeneratorOptionsPanel
!= NULL
)
31 m_CGeneratorOptionsPanel
->ParameterChanged(this);
34 ar(Serialization::Callback(m_valueFloat
, callback
), "Float", "^");
36 else if (m_TODParamType
== ELodParamType::eIntType
)
38 auto callback
= [&](int v
)
42 if(m_CGeneratorOptionsPanel
!= NULL
)
43 m_CGeneratorOptionsPanel
->ParameterChanged(this);
46 ar(Serialization::Callback(m_valueInt
, callback
), "I32", "^");
48 else if (m_TODParamType
== ELodParamType::eBoolType
)
50 auto callback
= [&](bool v
)
54 if(m_CGeneratorOptionsPanel
!= NULL
)
55 m_CGeneratorOptionsPanel
->ParameterChanged(this);
58 ar(Serialization::Callback(m_valueBool
, callback
), "bool", "^");
60 else if (m_TODParamType
== ELodParamType::eStringType
)
62 auto callback
= [&](string v
)
66 if(m_CGeneratorOptionsPanel
!= NULL
)
67 m_CGeneratorOptionsPanel
->ParameterChanged(this);
70 ar(Serialization::Callback(m_valueString
, callback
), "string", "^");
86 } s_propertyTypeNames
[] =
88 { IVariable::DT_SIMPLE
,"Bool",PropertyType::ePropertyBool
,2 },
89 { IVariable::DT_SIMPLE
,"Int",PropertyType::ePropertyInt
,0 },
90 { IVariable::DT_SIMPLE
,"Float",PropertyType::ePropertyFloat
,0 },
91 { IVariable::DT_SIMPLE
,"Vector",PropertyType::ePropertyVector2
,10 },
92 { IVariable::DT_SIMPLE
,"Vector",PropertyType::ePropertyVector
,10 },
93 { IVariable::DT_SIMPLE
,"Vector",PropertyType::ePropertyVector4
,10 },
94 { IVariable::DT_SIMPLE
,"String",PropertyType::ePropertyString
,3 },
95 { IVariable::DT_PERCENT
,"Float",PropertyType::ePropertyInt
,13 },
96 { IVariable::DT_BOOLEAN
,"Boolean",PropertyType::ePropertyBool
,2 },
97 { IVariable::DT_COLOR
,"Color",PropertyType::ePropertyColor
,1 },
98 { IVariable::DT_CURVE
|IVariable::DT_PERCENT
,"FloatCurve",PropertyType::ePropertyFloatCurve
,13 },
99 { IVariable::DT_CURVE
|IVariable::DT_COLOR
,"ColorCurve",PropertyType::ePropertyColorCurve
,1 },
100 { IVariable::DT_ANGLE
,"Angle",PropertyType::ePropertyAngle
,0 },
101 { IVariable::DT_FILE
,"File",PropertyType::ePropertyFile
,7 },
102 { IVariable::DT_TEXTURE
,"Texture",PropertyType::ePropertyTexture
,4 },
103 { IVariable::DT_ANIMATION
,"Animation",PropertyType::ePropertyAnimation
,-1 },
104 { IVariable::DT_OBJECT
,"Model",PropertyType::ePropertyModel
,5 },
105 { IVariable::DT_SIMPLE
,"Selection",PropertyType::ePropertySelection
,-1 },
106 { IVariable::DT_SIMPLE
,"List",PropertyType::ePropertyList
,-1 },
107 { IVariable::DT_SHADER
,"Shader",PropertyType::ePropertyShader
,9 },
108 { IVariable::DT_MATERIAL
,"Material",PropertyType::ePropertyMaterial
,14 },
109 { IVariable::DT_AI_BEHAVIOR
,"AIBehavior",PropertyType::ePropertyAiBehavior
,8 },
110 { IVariable::DT_AI_ANCHOR
,"AIAnchor",PropertyType::ePropertyAiAnchor
,8 },
111 #ifdef USE_DEPRECATED_AI_CHARACTER_SYSTEM
112 { IVariable::DT_AI_CHARACTER
,"AICharacter",PropertyType::ePropertyAiCharacter
,8 },
114 { IVariable::DT_AI_PFPROPERTIESLIST
,"AgentTypeList",PropertyType::ePropertyAiPFPropertiesList
,8 },
115 { IVariable::DT_AIENTITYCLASSES
,"AI Entity Classes",PropertyType::ePropertyAiEntityClasses
,8 },
116 { IVariable::DT_EQUIP
,"Equip",PropertyType::ePropertyEquip
,11 },
117 { IVariable::DT_REVERBPRESET
,"ReverbPreset",PropertyType::ePropertyReverbPreset
,11 },
118 { IVariable::DT_LOCAL_STRING
,"LocalString",PropertyType::ePropertyLocalString
,3 },
119 { IVariable::DT_SOCLASS
,"Smart Object Class",PropertyType::ePropertySOClass
,8 },
120 { IVariable::DT_SOCLASSES
,"Smart Object Classes",PropertyType::ePropertySOClasses
,8 },
121 { IVariable::DT_SOSTATE
,"Smart Object State",PropertyType::ePropertySOState
,8 },
122 { IVariable::DT_SOSTATES
,"Smart Object States",PropertyType::ePropertySOStates
,8 },
123 { IVariable::DT_SOSTATEPATTERN
,"Smart Object State Pattern",PropertyType::ePropertySOStatePattern
,8 },
124 { IVariable::DT_SOACTION
,"AI Action",PropertyType::ePropertySOAction
,8 },
125 { IVariable::DT_SOHELPER
,"Smart Object Helper",PropertyType::ePropertySOHelper
,8 },
126 { IVariable::DT_SONAVHELPER
,"Smart Object Navigation Helper",PropertyType::ePropertySONavHelper
,8 },
127 { IVariable::DT_SOANIMHELPER
,"Smart Object Animation Helper",PropertyType::ePropertySOAnimHelper
,8 },
128 { IVariable::DT_SOEVENT
,"Smart Object Event",PropertyType::ePropertySOEvent
,8 },
129 { IVariable::DT_SOTEMPLATE
,"Smart Object Template",PropertyType::ePropertySOTemplate
,8 },
130 { IVariable::DT_CUSTOMACTION
,"Custom Action",PropertyType::ePropertyCustomAction
,7 },
131 { IVariable::DT_VEEDHELPER
,"Vehicle Helper",PropertyType::ePropertySelection
,-1 },
132 { IVariable::DT_VEEDPART
,"Vehicle Part",PropertyType::ePropertySelection
,-1 },
133 { IVariable::DT_VEEDCOMP
,"Vehicle Component",PropertyType::ePropertySelection
,-1 },
134 { IVariable::DT_GAMETOKEN
,"Game Token",PropertyType::ePropertyGameToken
, -1 },
135 { IVariable::DT_SEQUENCE
,"Sequence",PropertyType::ePropertySequence
, -1 },
136 { IVariable::DT_MISSIONOBJ
,"Mission Objective",PropertyType::ePropertyMissionObj
, -1 },
137 { IVariable::DT_USERITEMCB
,"User",PropertyType::ePropertyUser
, -1 },
138 { IVariable::DT_AITERRITORY
,"AITerritory",PropertyType::ePropertyAiTerritory
,8 },
139 { IVariable::DT_AIWAVE
,"AIWave",PropertyType::ePropertyAiWave
,8 },
140 { IVariable::DT_SEQUENCE_ID
,"SequenceId",PropertyType::ePropertySequenceId
, -1 },
141 //{ IVariable::DT_LIGHT_ANIMATION,"LightAnimation",PropertyType::ePropertyLightAnimation, -1 },
142 { IVariable::DT_FLARE
,"Flare",PropertyType::ePropertyFlare
,7 },
143 { IVariable::DT_PARTICLE_EFFECT
,"ParticleEffect",PropertyType::ePropertyParticleName
, 3 },
144 { IVariable::DT_GEOM_CACHE
,"Geometry Cache",PropertyType::ePropertyGeomCache
,5 },
145 { IVariable::DT_AUDIO_TRIGGER
,"Audio Trigger",PropertyType::ePropertyAudioTrigger
,6 },
146 { IVariable::DT_AUDIO_SWITCH
,"Audio Switch",PropertyType::ePropertyAudioSwitch
,6 },
147 { IVariable::DT_AUDIO_SWITCH_STATE
,"Audio Switch",PropertyType::ePropertyAudioSwitchState
,6 },
148 { IVariable::DT_AUDIO_RTPC
,"Audio Realtime Parameter Control",PropertyType::ePropertyAudioRTPC
,6 },
149 { IVariable::DT_AUDIO_ENVIRONMENT
,"Audio Environment",PropertyType::ePropertyAudioEnvironment
,6 },
150 { IVariable::DT_AUDIO_PRELOAD_REQUEST
,"Audio Preload Request",PropertyType::ePropertyAudioPreloadRequest
,6 },
152 static int NumPropertyTypes
= sizeof(s_propertyTypeNames
)/sizeof(s_propertyTypeNames
[0]);
154 void GetVariableParams( IVariable
*var
,PropertyType
& pType
,float& fMin
,float& fMax
,float& fStep
);
156 ELodParamType
SLodParameter::GetLodParamType(IVariable
* pCurVariable
)
158 ELodParamType eLodParamType
= eUNKownType
;
163 GetVariableParams(pCurVariable
,pType
,fMin
,fMax
,fStep
);
167 case ePropertyInvalid
:
172 eLodParamType
= eBoolType
;
175 eLodParamType
= eIntType
;
178 eLodParamType
= eFloatType
;
180 case ePropertyVector2
:
182 case ePropertyVector
:
184 case ePropertyVector4
:
186 case ePropertyString
:
187 eLodParamType
= eStringType
;
190 eLodParamType
= eColorType
;
194 case ePropertyFloatCurve
:
196 case ePropertyColorCurve
:
200 case ePropertyTexture
:
202 case ePropertyAnimation
:
206 case ePropertySelection
:
210 case ePropertyShader
:
212 case ePropertyMaterial
:
214 case ePropertyAiBehavior
:
216 case ePropertyAiAnchor
:
218 case ePropertyAiPFPropertiesList
:
220 case ePropertyAiEntityClasses
:
222 case ePropertyAiTerritory
:
224 case ePropertyAiWave
:
228 case ePropertyReverbPreset
:
230 case ePropertyLocalString
:
232 case ePropertySOClass
:
234 case ePropertySOClasses
:
236 case ePropertySOState
:
238 case ePropertySOStates
:
240 case ePropertySOStatePattern
:
242 case ePropertySOAction
:
244 case ePropertySOHelper
:
246 case ePropertySONavHelper
:
248 case ePropertySOAnimHelper
:
250 case ePropertySOEvent
:
252 case ePropertySOTemplate
:
254 case ePropertyCustomAction
:
256 case ePropertyGameToken
:
258 case ePropertySequence
:
260 case ePropertyMissionObj
:
264 case ePropertySequenceId
:
266 /*case ePropertyLightAnimation:
270 case ePropertyParticleName
:
272 case ePropertyGeomCache
:
274 case ePropertyAudioTrigger
:
276 case ePropertyAudioSwitch
:
278 case ePropertyAudioSwitchState
:
280 case ePropertyAudioRTPC
:
282 case ePropertyAudioEnvironment
:
284 case ePropertyAudioPreloadRequest
:
290 return eLodParamType
;
293 void GetVariableParams( IVariable
*var
,PropertyType
& pType
,float& fMin
,float& fMax
,float& fStep
)
295 _smart_ptr
<IVariable
> pInputVar
= var
;
297 int dataType
= var
->GetDataType();
298 string m_name
= var
->GetHumanName();
299 pType
= ePropertyInvalid
;
302 if (dataType
!= IVariable::DT_SIMPLE
)
304 for (i
= 0; i
< NumPropertyTypes
; i
++)
306 if (dataType
== s_propertyTypeNames
[i
].dataType
)
308 pType
= s_propertyTypeNames
[i
].type
;
314 IVarEnumList
* enumList
= var
->GetEnumList();
315 if (enumList
!= NULL
)
317 pType
= ePropertySelection
;
320 if (pType
== ePropertyInvalid
)
322 switch(var
->GetType())
325 pType
= ePropertyInt
;
327 case IVariable::BOOL
:
328 pType
= ePropertyBool
;
330 case IVariable::FLOAT
:
331 pType
= ePropertyFloat
;
333 case IVariable::VECTOR2
:
334 pType
= ePropertyVector2
;
336 case IVariable::VECTOR4
:
337 pType
= ePropertyVector4
;
339 case IVariable::VECTOR
:
340 pType
= ePropertyVector
;
342 case IVariable::STRING
:
343 pType
= ePropertyString
;
348 float m_valueMultiplier
= 1;
349 float m_rangeMin
= 0;
350 float m_rangeMax
= 100;
352 bool m_bHardMin
= false;
353 bool m_bHardMax
= false;
354 // Get variable limits.
355 var
->GetLimits( m_rangeMin
, m_rangeMax
, m_step
, m_bHardMin
, m_bHardMax
);
357 // Check if value is percents.
358 if (dataType
== IVariable::DT_PERCENT
)
360 // Scale all values by 100.
361 m_valueMultiplier
= 100;
363 else if (dataType
== IVariable::DT_ANGLE
)
365 // Scale radians to degrees.
366 m_valueMultiplier
= RAD2DEG(1);
370 else if (dataType
== IVariable::DT_UIENUM
)
372 //CUIEnumsDatabase_SEnum* m_pEnumDBItem = GetIEditor()->GetUIEnumsDatabase()->FindEnum(m_name);
376 const bool useExplicitStep
= (var
->GetFlags() & IVariable::UI_EXPLICIT_STEP
);
377 if (!useExplicitStep
)
379 // Limit step size to 1000.
380 int nPrec
= max(3 - int(log(m_rangeMax
- m_rangeMin
) / log(10.f
)), 0);
381 m_step
= max(m_step
, powf(10.f
, -nPrec
));