aboutsummaryrefslogtreecommitdiff
path: root/vrayPlug/plugin/shaveVrayMovingTriVoxelPrim.h
blob: e3bc821d035bfb445e13cf0ae16681a9c2e326ea (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
#ifndef _HAIR_VR_MOVING_tri_VOXEL_PRIMITIVE_H_
#define _HAIR_VR_MOVING_tri_VOXEL_PRIMITIVE_H_

// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

/**********************************************************************
 *<
	FILE:			shaveVrayMovingTriVoxelPrim.h  

	DESCRIPTION:	Moving (motion blurred) hair instanced hair voxel primitive

	CREATED BY:		Vladimir Dubovoy <[email protected]>

	HISTORY:		created  20-05-2010 

 *>
 **********************************************************************/

#include "shaveVrayTriVoxelPrim.h"
#include "hairprimitives.h"

#include <vector>


class shaveVrayMovingTriVoxelPrim : public shaveVrayTriVoxelPrim,
							        public VR::MovingPrimitive {
public:
	shaveVrayMovingTriVoxelPrim(IHairVoxel* voxel, VR::VRayCore *vray, shaveVrayInstanceI* inst);
	virtual ~shaveVrayMovingTriVoxelPrim();

	/*
	|	from MovingPrimitive
	*/
	// Return the bounding box of this primitive. 
	void  getBBox (VR::MovingBox &bbox);
	
	//Return true if the primitive is splittable. 
	bool  splittable ();
	
	//Return the bounding boxes of the primitive with respect to a given plane. 
 	void  split (int dim, VR::real middle, VR::MovingBox &bLeft, VR::MovingBox &bRight);

	//Return true here
	int expandable(); 
  
	//Expand the primitive into other sub-primitives. 
	int  expand (VR::DynamicRaycaster< VR::MovingBox > *raycaster, int threadIndex); 
  
	//Collapse the primitive. 
	int  collapse (VR::DynamicRaycaster< VR::MovingBox > *raycaster, int threadIndex); 

	/*
	|	from GeometryGenerator
	*/
	void setIntersectionData(VR::RSRay &rsray, void *isData);

#if defined VRAY30
	void setIntersectionData(const VR::RayBunchParams&   params,
							 VR::PrimitiveIntersections& result, 
							 const RAY_IDX*  idxs,
							 size_t count);
#endif

#ifdef OWN_SHADEABLE_FOR_TRI
	VR::Shadeable* getShadeable() { return shade(); }
#else
	VR::Shadeable* getShadeable() { return shdata(); }
#endif
	VR::VRayShadeInstance* getExtShadeData() { return NULL; }
	VR::VRayShadeData* getExtTexMapping() { return shdata(); }
	VR::VRayVolume* getVolumeShader() { return NULL; }
	VR::VRaySurfaceProperties* getExtSurfaceProperties() { return NULL; }

protected:
	
	//const member access
	inline const VR::MovingBox&      bbox()		const {return m_bbox;}
	inline const std::vector<VR::Vector>& normals() const {return m_normals;}
	inline const VR::Vector& normal(int i) const {return m_normals[i];}
	inline const VR::MovingTriangle& tri(int i) const {return m_tris[i];}
	inline VR::MovingTriangle*		 tris()		const {return m_tris;}
	inline int						firstid()   const {return m_firstid;}
	//inline int						numblur()	const {return m_numblur;}
	
	//member access
	inline VR::MovingBox&       _bbox()		{return m_bbox;}
	inline std::vector<VR::Vector>& _normals()	{return m_normals;}
	inline VR::Vector& _normal(int i)			{return m_normals[i];}
	inline VR::MovingTriangle&  _tri(int i) {return m_tris[i];}
	inline VR::MovingTriangle*& _tris()		{return m_tris;}
	inline int&					_firstid()  {return m_firstid;}
	//inline int&					_numblur()	{return m_numblur;}


private:
	
	VR::MovingBox m_bbox;
	int	m_firstid;
	//int m_numblur; //it is just 2
	VR::MovingTriangle* m_tris;
	std::vector<VR::Vector> m_normals;
	
};


#endif	//end of_HAIR_VR_MOVING_tri_VOXEL_PRIMITIVE_H_