Signed Distance Fields 1.0
|
Signed distance field construction tree. More...
#include <sdf.h>
Public Member Functions | |
SDFTree (SDFNode *) | |
Constructor. | |
~SDFTree () | |
Destructor. | |
void | ComputeCost (const Vector &) const |
Computes the signed distance to the surface. | |
double | Value (const Vector &) const |
Computes the signed distance to the surface. | |
Vector | Gradient (const Vector &) const |
Compute the gradient of the field. | |
Vector | Normal (const Vector &) const |
Compute the normal of the field. | |
bool | Inside (const Vector &) const |
Check if a point is inside or outside. | |
Color | GetColor (const Vector &) const |
Compute the color. | |
void | setUseBID (bool) |
Set the value of useBID so that the function value use or not the BID method. | |
double | K () const |
Computes the Lipschitz constant of the construction tree. | |
Box | GetBox () const |
Get the bounding box of the construction tree. | |
void | Union (SDFNode *) |
Apply an union operator between the root and paremeter. | |
void | Intersection (SDFNode *) |
Apply an intersection operator between the root and paremeter. | |
void | Difference (SDFNode *) |
Apply a difference operator between the root and paremeter. | |
void | SmoothDifference (SDFNode *, double) |
Apply a smooth difference operator between the root and paremeter. | |
void | SmoothUnion (SDFNode *, double) |
Apply a smooth union operator between the root and paremeter. | |
void | AddSphere (const Vector &, double, double) |
Adds a sphere. | |
bool | SphereTrace (const Ray &, 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 Ray &, Vector &) const |
Intersection with the construction tree, using sphere tracing. | |
void | PolygonizeMultithreadSplit (int, int, QVector< Mesh > &, const Box &) const |
Polygonization into multiple mesh to virtually increase maximum resolution. | |
virtual int | Memory () const |
Computes the memory used by the construction tree. | |
int | Nodes () const |
Returns the number of nodes in the tree. | |
SDFNode * | Root () const |
Returns the root of the tree. | |
QString | TimingsGradientAnalytic (int) const |
Computes the timings (in ms) for the analytic (if available) gradient function of the construction tree. | |
QString | TimingsGradientNumerical (int) const |
Computes the timings (in ms) for the numerical gradient function of the construction tree. | |
QString | Timings (int) const |
Computes the timings (in ms) for the field function of the construction tree. | |
QString | GetShader (bool materialShader=true, bool costShader=true, bool gradShader=true) const |
create the GLSL code to render the SDF using sphereTracing.glsl | |
QString | GetShaderIndented (bool materialShader=true, bool costShader=true, bool gradShader=true) const |
create the GLSL code to render the SDF using sphereTracing.glsl | |
Static Public Member Functions | |
static void | ResetCalls () |
Reset the call property of the tree. | |
static int | Calls () |
Returns the number of calls to Value(). | |
static void | ResetReccursiveCalls () |
Reset the reccursive call property of the tree. | |
static int | ReccursiveCalls () |
Returns the number of reccursive calls to Value() and BID(). | |
static void | setComputeNbReccursiveCalls (bool computeRecCalls) |
Set the static boolean computeNbReccursiveCalls to allow computation of nb of reccursive call in the function Value. | |
Protected Attributes | |
SDFNode * | root = 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). | |
Signed distance field construction tree.
|
explicit |
Constructor.
r | Root node. |
void SDFTree::AddSphere | ( | const Vector & | c, |
double | r, | ||
double | e ) |
Adds a sphere.
c | Center. |
r | Radius. |
e | Energy. |
void SDFTree::ComputeCost | ( | const Vector & | p | ) | const |
Computes the signed distance to the surface.
p | Point. |
void SDFTree::Difference | ( | SDFNode * | n | ) |
Apply a difference operator between the root and paremeter.
n | node. |
QString SDFTree::GetShader | ( | bool | materialShader = true, |
bool | costShader = true, | ||
bool | gradShader = true ) const |
create the GLSL code to render the SDF using sphereTracing.glsl
QString SDFTree::GetShaderIndented | ( | bool | materialShader = true, |
bool | costShader = true, | ||
bool | gradShader = true ) const |
create the GLSL code to render the SDF using sphereTracing.glsl
bool SDFTree::Inside | ( | const Vector & | p | ) | const |
Check if a point is inside or outside.
p | Point. |
void SDFTree::Intersection | ( | SDFNode * | n | ) |
Apply an intersection operator between the root and paremeter.
n | node to be intersected with root. |
void SDFTree::PolygonizeMultithreadSplit | ( | int | nGlobal, |
int | nMesh, | ||
QVector< Mesh > & | meshes, | ||
const Box & | box ) const |
Polygonization into multiple mesh to virtually increase maximum resolution.
nGlobal | global grid resolution. n^2 meshes are created. |
nMesh | individual grid resolution. |
meshes | Mesh vector, should be empty. |
box | The box. |
void SDFTree::SmoothDifference | ( | SDFNode * | n, |
double | t ) |
Apply a smooth difference operator between the root and paremeter.
n | node. |
t | Smoothing radius. |
void SDFTree::SmoothUnion | ( | SDFNode * | n, |
double | t ) |
Apply a smooth union operator between the root and paremeter.
n | node. |
t | Smoothing radius. |
|
virtual |
Find the first intersection between a ray and the object.
ray | The ray |
k | Lipschitz constant. |
a,b | Searching interval. |
t | Returned intersection depth. |
s | Returned step count. |
epsilon | Minimum stepping distance. |
Reimplemented from AnalyticScalarField.
QString SDFTree::Timings | ( | int | n | ) | const |
Computes the timings (in ms) for the field function of the construction tree.
n | Number of calls |
QString SDFTree::TimingsGradientAnalytic | ( | int | n | ) | const |
Computes the timings (in ms) for the analytic (if available) gradient function of the construction tree.
n | Number of calls |
QString SDFTree::TimingsGradientNumerical | ( | int | n | ) | const |
Computes the timings (in ms) for the numerical gradient function of the construction tree.
n | Number of calls |
void SDFTree::Union | ( | SDFNode * | n | ) |
Apply an union operator between the root and paremeter.
n | node to be unioned with root. |
|
virtual |
Computes the signed distance to the surface.
p | Point. |
Reimplemented from AnalyticScalarField.