Signed Distance Fields 1.0

Base planar signed distance node. ,. More...

#include <sdf.h>

Inheritance diagram for SDFNode2:
SDFBinary2 SDFPrimitive2 SDFUnary2 SDFDifference2 SDFIntersection2 SDFSmoothDifference2 SDFSmoothIntersection2 SDFSmoothUnion2 SDFUnion2 SDFEuclidean2 SDFQuadricCylinder2 SDFFrame2 SDFNoise2 SDFPlanarSymmetry2 SDFRevolutionSymmetry2 SDFRotate2 SDFRound2 SDFScale2 SDFThickSurface2 SDFTranslate2 SDFTurbulence2 SDFUniformScale2

Public Member Functions

 SDFNode2 ()
 Create a generic node.
 
virtual ~SDFNode2 ()
 Destructor.
 
virtual double Signed (const Vector2 &) const
 Compute the signed distance.
 
virtual Vector2 Gradient (const Vector2 &) const
 Compute the gradient of the field.
 
virtual bool Inside (const Vector2 &) const
 Check if a point is inside or outside.
 
virtual QString GetShader (PrimitiveManager *, std::list< QString > *, bool *=nullptr) const
 Compute the GLSL code to render the node.
 
virtual QString GetGradientShader (PrimitiveManager *, std::list< QString > *, bool *=nullptr) const
 Compute the GLSL code to compute the gradient the sdf.
 
virtual QString GetCostShader (PrimitiveManager *, std::list< QString > *, bool *) const
 Compute the GLSL code to compute the cost of a call to sdf.
 
virtual void ComputeCostSigned (const Vector2 &)
 Compute the number of reccursive calls to Signed().
 
virtual int Memory () const
 Return the size of a sub-tree.
 
virtual double K () const
 Return the Lipschitz constant of the node.
 
Box2 GetBox () const
 Return the bounding box of the node.
 
virtual int Nodes () const
 Compute the number of nodes in the sub-tree.
 

Protected Attributes

Box2 box = Box2::Infinity
 Box bounding the surface.
 
double k = 1.0
 Lipschitz constant.
 
int cost = 1
 Cost of the node.
 

Static Protected Attributes

static constexpr double Epsilon = 0.01
 Small constant used for bounding volumes.
 

Detailed Description

Base planar signed distance node. ,.

Constructor & Destructor Documentation

◆ SDFNode2()

SDFNode2::SDFNode2 ( )
explicit

Create a generic node.

Internally set Lipschitz bound to 1.0.

Member Function Documentation

◆ ComputeCostSigned()

void SDFNode2::ComputeCostSigned ( const Vector2 & p)
virtual

Compute the number of reccursive calls to Signed().

Author
Hubert-Brierre Pierre

Reimplemented in SDFBinary2, SDFFrame2, SDFPrimitive2, SDFRotate2, SDFScale2, SDFTranslate2, SDFUnary2, and SDFUniformScale2.

◆ GetCostShader()

QString SDFNode2::GetCostShader ( PrimitiveManager * primitives,
std::list< QString > * dependency,
bool * valid_glsl ) const
virtual

Compute the GLSL code to compute the cost of a call to sdf.

Author
Hubert-Brierre Pierre

Reimplemented in SDFBinary2, SDFFrame2, SDFIntersection2, SDFPrimitive2, SDFRotate2, SDFScale2, SDFTranslate2, SDFUnary2, and SDFUniformScale2.

◆ GetGradientShader()

QString SDFNode2::GetGradientShader ( PrimitiveManager * primitives,
std::list< QString > * dependency,
bool * valid_glsl = nullptr ) const
virtual

Compute the GLSL code to compute the gradient the sdf.

Author
HUEBRT-BRIERRE Pierre

◆ GetShader()

QString SDFNode2::GetShader ( PrimitiveManager * primitives,
std::list< QString > * dependency,
bool * valid_glsl = nullptr ) const
virtual

◆ Gradient()

Vector2 SDFNode2::Gradient ( const Vector2 & p) const
virtual

Compute the gradient of the field.

Parameters
pPoint.

◆ Inside()

bool SDFNode2::Inside ( const Vector2 & p) const
virtual

Check if a point is inside or outside.

Parameters
pPoint.

◆ K()

double SDFNode2::K ( ) const
virtual

Return the Lipschitz constant of the node.

By default, nodes are considered as signed Euclidean distance functions, and the Lipschitz consistant is λ=1.

Reimplemented in SDFUnary2.

◆ Signed()