Commit 4969a0c9 authored by Philip Trettner's avatar Philip Trettner
Browse files

working on tracing

parent 866ff765
......@@ -4,6 +4,29 @@ A lightweight half-edge data structure.
Best used with glm and glow.
## Function parameter order guide
The following types of parameters exist:
* M (`Mesh const& m` or `Mesh& m`) reference to mesh (depending on topology is modified)
* RO-A (`attribute<T> const&`) read-only attributes such as position
* RW-A (`attribute<T>&`) read-write attributes
* OPT-A (`attribute<T>* = nullptr` or `attribute<T> const* = nullptr`) optional attributes
* H (`handle h`) handle
* M-P: other mandatory parameters
* OPT-P: other optional parameters
* OUT-P: output parameters (that don't fit in the return value)
Free functions that perform mesh-related algorithms follow these rules for their parameters:
* Mesh (M) or handle (H) is first parameter ("what does this function operates on?")
* Followed by all required RO-A such as `position`
* Followed by all mandatory parameters M-P
* Followed by all additional outputs RW-A and OUT-P
* Finalized by all optional parameters OPT-A and OPT-P (least frequently used parameter should be last)
## TODO
* Properties
......
#pragma once
#include "../Mesh.hh"
#include "../fields.hh"
namespace polymesh
{
/**
* Traces a ray inside the triangle stopping at the next edge
*/
/// Traces from halfedge h into its triangle
/// Start point is given by interpolating h.from and h.to given x
/// Direction is given by virtual source with SQUARED distance d1_sqr from h.from and d2_sqr from h.to
/// Returns intersecting half-edge and new x parameter
template <class Scalar = float, class EdgeLengthF>
std::pair<halfedge_handle, float> trace_step(halfedge_handle h, EdgeLengthF&& edge_length, Scalar x, Scalar d1_sqr, Scalar d2_sqr);
/// ======== IMPLEMENTATION ========
template <class Scalar, class EdgeLengthF>
std::pair<halfedge_handle, float> trace_step(halfedge_handle h, EdgeLengthF&& edge_length, Scalar x, Scalar d1_sqr, Scalar d2_sqr)
{
assert(!h.is_boundary() && "cannot trace into boundary");
auto f = h.face();
assert(f.vertices().size() == 3 && "only supports triangles");
// TODO
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment