Castor3D  ..
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Castor3D::Subdivider Class Referenceabstract

Subdividers main class C3D_API. More...

+ Collaboration diagram for Castor3D::Subdivider:

Public Member Functions

C3D_API Subdivider ()
 Default constructor. More...
 
virtual C3D_API ~Subdivider ()
 Destructor. More...
 
virtual C3D_API void Subdivide (SubmeshSPtr p_submesh, int p_occurences, bool p_generateBuffers=true, bool p_threaded=false)
 Main subdivision function. More...
 
virtual C3D_API void Cleanup ()
 Cleans all member variables. More...
 
C3D_API BufferElementGroupSPtr AddPoint (real x, real y, real z)
 Creates and adds a vertex to my list. More...
 
C3D_API BufferElementGroupSPtr AddPoint (Castor::Point3r const &p_v)
 Adds a vertex to my list. More...
 
C3D_API BufferElementGroupSPtr AddPoint (real *p_v)
 Creates and adds a vertex to my list. More...
 
virtual C3D_API Face AddFace (uint32_t a, uint32_t b, uint32_t c)
 Creates and adds a face. More...
 
virtual C3D_API int IsInMyPoints (Castor::Point3r const &p_vertex, double p_precision)
 Tests if the given Point3r is in mine. More...
 
C3D_API uint32_t GetPointsCount () const
 Retrieves the points count. More...
 
C3D_API BufferElementGroupSPtr GetPoint (uint32_t i) const
 Retrieves the wanted point. More...
 
C3D_API VertexPtrArray const & GetPoints () const
 
void SetSubdivisionEndCallback (SubdivisionEndFunction p_pfnSubdivisionEnd)
 Defines a function to execute when the threaded subdivision ends. More...
 

Protected Types

typedef std::function< void(Subdivider &) > SubdivisionEndFunction
 

Protected Member Functions

C3D_API uint32_t DoSubdivideThreaded ()
 Threaded subdivision function. More...
 
C3D_API Castor3D::BufferElementGroupSPtr DoTryAddPoint (Castor::Point3r const &p_point)
 Checks if the given point is in my list and if not creates and adds it. More...
 
virtual C3D_API void DoSubdivide (SubmeshSPtr p_submesh, bool p_generateBuffers, bool p_threaded)
 Main subdivision function. More...
 
virtual C3D_API void DoInitialise ()
 Initialisation function. More...
 
C3D_API void DoSwapBuffers ()
 Swaps the internal faces with the submeshes ones. More...
 
virtual C3D_API void DoSubdivide ()=0
 Effectively subdivides the submesh. More...
 
C3D_API void DoSetTextCoords (BufferElementGroup const &p_a, BufferElementGroup const &p_b, BufferElementGroup const &p_c, BufferElementGroup &p_d, BufferElementGroup &p_e, BufferElementGroup &p_f)
 Computes the texture coordinates for given vertices, creates the faces. More...
 
C3D_API void DoSetTextCoords (BufferElementGroup const &p_a, BufferElementGroup const &p_b, BufferElementGroup const &p_c, BufferElementGroup &p_p)
 Computes the texture coordinates for the new vertex, creates the faces. More...
 

Protected Attributes

SubmeshSPtr m_submesh
 The submesh being subdivided. More...
 
FaceArray m_arrayFaces
 The faces. More...
 
bool m_bGenerateBuffers
 Tells if the buffers must be generatef. More...
 
SubdivisionEndFunction m_pfnSubdivisionEnd
 The subdivision end callback. More...
 
std::shared_ptr< std::thread > m_pThread
 The subdivision thread. More...
 
bool m_bThreaded
 Tells that the subdivision is threaded. More...
 
std::recursive_mutex m_mutex
 The subdivision thread mutex. More...
 

Detailed Description

Subdividers main class C3D_API.

Author
Sylvain DOREMUS
Date
12/03/2010
Remarks
Abstract class C3D_API for subdivisers, contains the header for the main Subdivide function

Member Typedef Documentation

◆ SubdivisionEndFunction

typedef std::function< void( Subdivider & ) > Castor3D::Subdivider::SubdivisionEndFunction
protected

Constructor & Destructor Documentation

◆ Subdivider()

C3D_API Castor3D::Subdivider::Subdivider ( )

Default constructor.

◆ ~Subdivider()

virtual C3D_API Castor3D::Subdivider::~Subdivider ( )
virtual

Destructor.

Member Function Documentation

◆ AddFace()

virtual C3D_API Face Castor3D::Subdivider::AddFace ( uint32_t  a,
uint32_t  b,
uint32_t  c 
)
virtual

Creates and adds a face.

Parameters
[in]aThe first face's vertex index
[in]bThe second face's vertex index
[in]cThe third face's vertex index
Returns
The created face

◆ AddPoint() [1/3]

C3D_API BufferElementGroupSPtr Castor3D::Subdivider::AddPoint ( real  x,
real  y,
real  z 
)

Creates and adds a vertex to my list.

Parameters
[in]x,y,zThe vertex coordinates
Returns
The created vertex

◆ AddPoint() [2/3]

C3D_API BufferElementGroupSPtr Castor3D::Subdivider::AddPoint ( Castor::Point3r const &  p_v)

Adds a vertex to my list.

Parameters
[in]p_vThe vertex to add
Returns
The created vertex

◆ AddPoint() [3/3]

C3D_API BufferElementGroupSPtr Castor3D::Subdivider::AddPoint ( real *  p_v)

Creates and adds a vertex to my list.

Parameters
[in]p_vThe vertex coordinates
Returns
The created vertex

◆ Cleanup()

virtual C3D_API void Castor3D::Subdivider::Cleanup ( )
virtual

Cleans all member variables.

◆ DoInitialise()

virtual C3D_API void Castor3D::Subdivider::DoInitialise ( )
protectedvirtual

Initialisation function.

◆ DoSetTextCoords() [1/2]

C3D_API void Castor3D::Subdivider::DoSetTextCoords ( BufferElementGroup const &  p_a,
BufferElementGroup const &  p_b,
BufferElementGroup const &  p_c,
BufferElementGroup p_d,
BufferElementGroup p_e,
BufferElementGroup p_f 
)
protected

Computes the texture coordinates for given vertices, creates the faces.

Parameters
[in]p_a,p_b,p_cThe source vertices
[in]p_d,p_e,p_fThe new vertices

◆ DoSetTextCoords() [2/2]

C3D_API void Castor3D::Subdivider::DoSetTextCoords ( BufferElementGroup const &  p_a,
BufferElementGroup const &  p_b,
BufferElementGroup const &  p_c,
BufferElementGroup p_p 
)
protected

Computes the texture coordinates for the new vertex, creates the faces.

Parameters
[in]p_a,p_b,p_cThe source vertices
[in]p_pThe new vertex

◆ DoSubdivide() [1/2]

virtual C3D_API void Castor3D::Subdivider::DoSubdivide ( SubmeshSPtr  p_submesh,
bool  p_generateBuffers,
bool  p_threaded 
)
protectedvirtual

Main subdivision function.

Parameters
[in]p_submeshThe submesh to subdivide
[in]p_generateBuffersTells if the buffers must be generated after subdivision
[in]p_threadedTells if subdivision must be threaded

◆ DoSubdivide() [2/2]

virtual C3D_API void Castor3D::Subdivider::DoSubdivide ( )
protectedpure virtual

Effectively subdivides the submesh.

◆ DoSubdivideThreaded()

C3D_API uint32_t Castor3D::Subdivider::DoSubdivideThreaded ( )
protected

Threaded subdivision function.

◆ DoSwapBuffers()

C3D_API void Castor3D::Subdivider::DoSwapBuffers ( )
protected

Swaps the internal faces with the submeshes ones.

◆ DoTryAddPoint()

C3D_API Castor3D::BufferElementGroupSPtr Castor3D::Subdivider::DoTryAddPoint ( Castor::Point3r const &  p_point)
protected

Checks if the given point is in my list and if not creates and adds it.

Parameters
[in]p_pointThe vertex coordinates
Returns
The created vertex

◆ GetPoint()

C3D_API BufferElementGroupSPtr Castor3D::Subdivider::GetPoint ( uint32_t  i) const

Retrieves the wanted point.

Parameters
[in]iThe point index
Returns
The value

◆ GetPoints()

C3D_API VertexPtrArray const& Castor3D::Subdivider::GetPoints ( ) const
Returns
Retrieves the points array

◆ GetPointsCount()

C3D_API uint32_t Castor3D::Subdivider::GetPointsCount ( ) const

Retrieves the points count.

Returns
The value

◆ IsInMyPoints()

virtual C3D_API int Castor3D::Subdivider::IsInMyPoints ( Castor::Point3r const &  p_vertex,
double  p_precision 
)
virtual

Tests if the given Point3r is in mine.

Parameters
[in]p_vertexThe vertex to test
[in]p_precisionThe comparison precision
Returns
The index of the vertex equal to parameter, -1 if not found

◆ SetSubdivisionEndCallback()

void Castor3D::Subdivider::SetSubdivisionEndCallback ( SubdivisionEndFunction  p_pfnSubdivisionEnd)
inline

Defines a function to execute when the threaded subdivision ends.

Remarks
That function MUST NEITHER destroy the thread NOR the subdivider
Parameters
[in]p_pfnSubdivisionEndPointer over the function to execute

References m_pfnSubdivisionEnd.

◆ Subdivide()

virtual C3D_API void Castor3D::Subdivider::Subdivide ( SubmeshSPtr  p_submesh,
int  p_occurences,
bool  p_generateBuffers = true,
bool  p_threaded = false 
)
virtual

Main subdivision function.

Parameters
[in]p_submeshThe submesh to subdivide
[in]p_occurencesThe subdivisions occurences
[in]p_generateBuffersTells if the buffers must be generated after subdivision
[in]p_threadedTells if subdivision must be threaded

Member Data Documentation

◆ m_arrayFaces

FaceArray Castor3D::Subdivider::m_arrayFaces
protected

The faces.

◆ m_bGenerateBuffers

bool Castor3D::Subdivider::m_bGenerateBuffers
protected

Tells if the buffers must be generatef.

◆ m_bThreaded

bool Castor3D::Subdivider::m_bThreaded
protected

Tells that the subdivision is threaded.

◆ m_mutex

std::recursive_mutex Castor3D::Subdivider::m_mutex
protected

The subdivision thread mutex.

◆ m_pfnSubdivisionEnd

SubdivisionEndFunction Castor3D::Subdivider::m_pfnSubdivisionEnd
protected

The subdivision end callback.

Referenced by SetSubdivisionEndCallback().

◆ m_pThread

std::shared_ptr< std::thread > Castor3D::Subdivider::m_pThread
protected

The subdivision thread.

◆ m_submesh

SubmeshSPtr Castor3D::Subdivider::m_submesh
protected

The submesh being subdivided.


The documentation for this class was generated from the following file: