blob: 5def8d1132c4168aa8fc1e6b1aacbf0470a67240 (
plain)
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
|
#pragma once
#include "Runtime/GameCode/Behaviour.h"
#include "Runtime/Filters/Renderer.h"
#include "Runtime/Math/Vector3.h"
class LODGroup : public Unity::Component
{
public:
struct LODRenderer
{
PPtr<Renderer> renderer;
DECLARE_SERIALIZE (LODRenderer)
};
typedef dynamic_array<LODRenderer> LODRenderers;
struct LOD
{
float screenRelativeHeight;
LODRenderers renderers;
LOD ()
: screenRelativeHeight (0.0F)
{ }
DECLARE_SERIALIZE (LOD)
};
typedef std::vector<LOD> LODArray;
REGISTER_DERIVED_CLASS (LODGroup, Component)
DECLARE_OBJECT_SERIALIZE(LODGroup)
LODGroup (MemLabelId label, ObjectCreationMode mode);
// virtual ~LODGroup (); declared-by-macro
virtual void Reset ();
virtual void SmartReset ();
virtual void CheckConsistency ();
virtual void AwakeFromLoad (AwakeFromLoadMode mode);
virtual void Deactivate (DeactivateOperation operation);
// Property get / set
Vector3f GetLocalReferencePoint () { return m_LocalReferencePoint; }
void SetLocalReferencePoint (const Vector3f& ref);
Vector3f GetWorldReferencePoint ();
float GetWorldSpaceSize ();
void UpdateEnabledState (bool active);
bool GetEnabled();
void SetEnabled(bool enabled);
float GetSize () const { return m_Size; }
void SetSize (float size);
int GetLODCount () const { return m_LODs.size(); }
const LOD& GetLOD (int index);
void SetLODArray (const LODArray& lodArray);
void GetLODArray (LODArray& lodArray) const { lodArray = m_LODs; }
int GetLODGroup () const { return m_LODGroup; }
// Interface for Renderer / Scene
void ClearCachedRenderers ();
void RegisterCachedRenderers ();
void RemoveFromCachedRenderers (Renderer* renderer);
void NotifyLODGroupManagerIndexChange (int newIndex);
void GetLODGroupIndexAndMask (Renderer* renderer, UInt32* outLODGroupIndex, UInt32* outActiveLODMask);
static void InitializeClass();
static void CleanupClass();
// Supported messages
void OnTransformChanged (int options);
float GetWorldSpaceScale ();
private:
void Create();
void Cleanup();
void SyncLODGroupManager ();
Vector3f m_LocalReferencePoint;
float m_Size;
LODArray m_LODs;
int m_LODGroup;
bool m_Enabled;
float m_ScreenRelativeTransitionHeight;
typedef dynamic_array<Renderer*> CachedRenderers;
CachedRenderers m_CachedRenderers;
friend class LODGroupManager;
};
struct MonoLOD
{
float screenRelativeTransitionHeight;
ScriptingArrayPtr renderers;
};
|