aboutsummaryrefslogtreecommitdiff
path: root/vrayPlug/plugin/shaveVrayStaticTriVoxelPrim.h
blob: ebcac5e1ec96475ccedc8e0dfaa966fda996901c (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
#ifndef _HAIR_VR_STATIC_tri_VOXEL_PRIMITIVE_H_
#define _HAIR_VR_STATIC_tri_VOXEL_PRIMITIVE_H_

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

/**********************************************************************
 *<
	FILE:			shaveVrayStaticTriVoxelPrim.h  

	DESCRIPTION:	Staic (non motion blurred) hair instanced hair voxel primitive

	CREATED BY:		Vladimir Dubovoy <[email protected]>

	HISTORY:		created  12-05-2010 

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

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

#include <vector>

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

	/*
	|	from StaicPrimitive
	*/
	// Return the bounding box of this primitive. 
	void  getBBox (VR::StaticBox &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::StaticBox &bLeft, VR::StaticBox &bRight);

	//Return true here
	int expandable(); 
  
	//Expand the primitive into other sub-primitives. 
	int  expand (VR::DynamicRaycaster< VR::StaticBox > *raycaster, int threadIndex); 
  
	//Collapse the primitive. 
	int  collapse (VR::DynamicRaycaster< VR::StaticBox > *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 std::vector<VR::Vector>& normals() const {return m_normals;}
	inline const VR::Vector& normal(int i) const {return m_normals[i];}
	inline const VR::StaticTriangle& tri(int i) const {return m_tris[i];}
	inline VR::StaticTriangle* tris()	  const {return m_tris;}
	inline int	  firstid()    const {return m_firstid;}
	
	//member access
	inline std::vector<VR::Vector>& _normals()	{return m_normals;}
	inline VR::Vector& _normal(int i)			{return m_normals[i];}
	inline VR::StaticTriangle&  _tri(int i)		{return m_tris[i];}
	inline VR::StaticTriangle*& _tris()			{return m_tris;}

	inline int&	   _firstid() {return m_firstid;}

private:
	
	int	m_firstid;
	VR::StaticTriangle* m_tris;
	std::vector<VR::Vector> m_normals;
};


#endif	//end of_HAIR_VR_STATIC_tri_VOXEL_PRIMITIVE_H_