aboutsummaryrefslogtreecommitdiff
path: root/APEX_1.4/module/iofx/include/RenderVolumeImpl.h
blob: bf6b7e1dddfd7e07c58b9724966d9ffa4f01fffb (plain) (blame)
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
/*
 * Copyright (c) 2008-2015, NVIDIA CORPORATION.  All rights reserved.
 *
 * NVIDIA CORPORATION and its licensors retain all intellectual property
 * and proprietary rights in and to this software, related documentation
 * and any modifications thereto.  Any use, reproduction, disclosure or
 * distribution of this software and related documentation without an express
 * license agreement from NVIDIA CORPORATION is strictly prohibited.
 */


#ifndef __RENDER_VOLUME_IMPL_H__
#define __RENDER_VOLUME_IMPL_H__

#include "Apex.h"
#include "RenderVolume.h"
#include "PsArray.h"
#include "ApexResource.h"
#include "ApexRenderable.h"
#include "ApexRWLockable.h"
#include "ReadCheck.h"
#include "WriteCheck.h"

namespace nvidia
{
namespace apex
{
class IofxAsset;
class IofxActor;
}
namespace iofx
{
class IofxScene;

class RenderVolumeImpl : public RenderVolume, public ApexResourceInterface, public ApexResource, public ApexRWLockable
{
public:
	APEX_RW_LOCKABLE_BOILERPLATE

	RenderVolumeImpl(IofxScene& scene, const PxBounds3& b, uint32_t priority, bool allIofx);
	~RenderVolumeImpl();

	// ApexResourceInterface methods
	void				release();
	void			    destroy();

	uint32_t	    getListIndex() const
	{
		return m_listIndex;
	}
	void	            setListIndex(ResourceList& list, uint32_t index)
	{
		m_listIndex = index;
		m_list = &list;
	}

	void				setOwnershipBounds(const PxBounds3& b)
	{
		WRITE_ZONE();
		mOwnershipBounds = b;
	}
	PxBounds3			getOwnershipBounds(void) const
	{
		READ_ZONE();
		return mOwnershipBounds;
	}
	PxBounds3			getBounds() const;

	// methods for use by IOS or IOFX actor
	bool				addIofxActor(IofxActor& iofx);
	bool				removeIofxActor(const IofxActor& iofx);

	bool				addIofxAsset(IofxAsset& iofx);
	void				setPosition(const PxVec3& pos);

	bool				getAffectsAllIofx() const
	{
		READ_ZONE();
		return mAllIofx;
	}

	IofxActor* const* lockIofxActorList(uint32_t& count)
	{
		READ_ZONE();
		mLock.lockReader();
		count = mIofxActors.size();
		return count ? &mIofxActors.front() : NULL;
	}
	void unlockIofxActorList()
	{
		mLock.unlockReader();
	}


	IofxAsset* const* getIofxAssetList(uint32_t& count) const
	{
		READ_ZONE();
		count = mIofxAssets.size();
		return count ? &mIofxAssets.front() : NULL;
	}
	PxVec3				getPosition() const
	{
		READ_ZONE();
		return mOwnershipBounds.getCenter();
	}
	uint32_t				getPriority() const
	{
		READ_ZONE();
		return mPriority;
	}
	bool				affectsIofxAsset(const IofxAsset& iofx) const;

	PX_INLINE void	lockReader()
	{
		mLock.lockReader();
	}
	PX_INLINE void	unlockReader()
	{
		mLock.unlockReader();
	}

protected:
	// bounds is stored in ApexRenderable::mRenderBounds
	uint32_t						mPriority;
	bool							mAllIofx;
	bool							mPendingDelete;
	IofxScene&						mScene;
	nvidia::Array<IofxAsset*>		mIofxAssets;
	nvidia::Array<IofxActor*>		mIofxActors;
	physx::PxBounds3				mOwnershipBounds;
	physx::shdfnd::ReadWriteLock	mLock;
};

}
} // namespace nvidia

#endif // __RENDER_VOLUME_IMPL_H__