Signed Distance Fields 1.0
SDFTree2 Class Reference

Signed distance field construction tree. More...

#include <sdf.h>

Inheritance diagram for SDFTree2:
AnalyticScalarField2

Public Member Functions

 SDFTree2 (SDFNode2 *)
 Constructor.
 
 ~SDFTree2 ()
 Destructor.
 
double Value (const Vector2 &) const
 Computes the signed distance to the surface.
 
Vector2 Gradient (const Vector2 &) const
 Compute the gradient of the field.
 
Vector2 Normal (const Vector2 &) const
 Compute the normal of the field.
 
bool Inside (const Vector2 &) const
 Check if a point is inside or outside.
 
double K () const
 Computes the Lipschitz constant of the construction tree.
 
Box2 GetBox () const
 Get the bounding box of the construction tree.
 
bool SphereTrace (const Ray2 &, const double &, const double &, const double &, double &, int &, const double &=0.001) const
 Find the first intersection between a ray and the object.
 
bool Intersect (const Ray2 &, Vector2 &) const
 Intersection with the construction tree, using sphere tracing.
 
virtual int Memory () const
 Computes the memory used by the construction tree.
 
int Nodes () const
 Returns the number of nodes in the tree.
 
SDFNode2Root () const
 Returns the root of the tree.
 

Static Public Member Functions

static void ResetCalls ()
 Reset the call property of the tree.
 
static int Calls ()
 Returns the number of calls to Value().
 

Protected Attributes

SDFNode2root = nullptr
 Root node.
 

Static Protected Attributes

static int calls = 0
 Number of call to SDFTree::Value(). <FONT COLOR="AA2222"><B>Warning</B></FONT> this will not give the correct number when used in a multi-threaded context (for example when raytracing the tree).
 

Detailed Description

Signed distance field construction tree.

Constructor & Destructor Documentation

◆ SDFTree2()

SDFTree2::SDFTree2 ( SDFNode2 * r)
explicit

Constructor.

Parameters
rRoot node.

Member Function Documentation

◆ Gradient()

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

Compute the gradient of the field.

Parameters
pPoint.

Reimplemented from AnalyticScalarField2.

◆ Inside()

bool SDFTree2::Inside ( const Vector2 & p) const

Check if a point is inside or outside.

Parameters
pPoint.

◆ Normal()

Vector2 SDFTree2::Normal ( const Vector2 & p) const

Compute the normal of the field.

Parameters
pPoint.

◆ SphereTrace()

bool SDFTree2::SphereTrace ( const Ray2 & ray,
const double & k,
const double & a,
const double & b,
double & t,
int & s,
const double & epsilon = 0.001 ) const

Find the first intersection between a ray and the object.

Parameters
rayThe ray
kLipschitz constant.
a,bSearching interval.
tReturned intersection depth.
sReturned step count.
epsilonMinimum stepping distance.

◆ Value()

double SDFTree2::Value ( const Vector2 & p) const
virtual

Computes the signed distance to the surface.

Parameters
pPoint.

Reimplemented from AnalyticScalarField2.