summaryrefslogtreecommitdiff
path: root/Runtime/Dynamics/ClothRenderer.h
blob: 06e4cd665ca293eba1397ccb68b7e593abcdf222 (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
#pragma once
#include "Configuration/UnityConfigure.h"

#if ENABLE_CLOTH

#include "Runtime/Filters/Renderer.h"

class VBO;

namespace Unity { class Cloth; }


class ClothRenderer : public Renderer
{
public:	
	REGISTER_DERIVED_CLASS (ClothRenderer, Renderer)
	DECLARE_OBJECT_SERIALIZE (ClothRenderer)

	ClothRenderer (MemLabelId label, ObjectCreationMode mode);
	
	virtual void AwakeFromLoad (AwakeFromLoadMode awakeMode);

	virtual void Reset ();	
	virtual void Render (int/* subsetIndex*/, const ChannelAssigns& channels);
	
	virtual void UpdateTransformInfo();
	
	virtual void RendererBecameVisible();
	virtual void RendererBecameInvisible();
	
	bool GetPauseWhenNotVisible() const { return m_PauseWhenNotVisible; }
	void SetPauseWhenNotVisible(bool pause) { SetDirty(); m_PauseWhenNotVisible = pause; }

	void UnloadVBOFromGfxDevice();
	void ReloadVBOToGfxDevice();
	
private:
	
	void UpdateClothVBOImmediate (int requiredChannels, UInt32& unavailableChannels);
	void UpdateClothVerticesFromPhysics ();
	void UpdateAABB ();
		
	VBO* m_VBO;
	UInt32 m_ChannelsInVBO;
	UInt32 m_UnavailableInVBO;
	AABB m_AABB;
	bool m_PauseWhenNotVisible;
	bool m_IsPaused;
	bool m_AABBDirty;
	
	friend class DeformableMesh;
};

#endif // ENABLE_CLOTH