diff options
author | Mai Lavelle <mai.lavelle@gmail.com> | 2019-08-14 08:53:09 +0300 |
---|---|---|
committer | Mai Lavelle <mai.lavelle@gmail.com> | 2019-08-27 21:27:53 +0300 |
commit | 697fd86506fd0caaa41e2fbf0463b5229d09251e (patch) | |
tree | 6f7b592ba6d00f5a4c4e92a0945fb0398c6572f0 /intern/cycles/subd/subd_split.h | |
parent | 7aef075ef6d07dca91444561da68d0233dc1a4c8 (diff) |
Cycles: Stitching of subdivided and displaced meshes
This patch stitches the vertices along patch edges so that cracks can
no longer form when applying subdivision or displacement a mesh.
Subpatches are now formed in a way that ensures vertex indices along
subpatch edges are equal for adjacent subpatches. A mapping of vertices
along patch edges is built to preform stitching. Overall performance is
roughly the same, some gains were made in splitting, but some was lost
in stitching.
This fixes:
- T49049 (cracks between patches from material and uv seams)
- T49048 (discontinuous normals with true displacement)
Reviewers: sergey, brecht
Differential Revision: https://developer.blender.org/D3692
Diffstat (limited to 'intern/cycles/subd/subd_split.h')
-rw-r--r-- | intern/cycles/subd/subd_split.h | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/intern/cycles/subd/subd_split.h b/intern/cycles/subd/subd_split.h index 6e68d8ee598..0fc22872c62 100644 --- a/intern/cycles/subd/subd_split.h +++ b/intern/cycles/subd/subd_split.h @@ -23,35 +23,51 @@ * for more details. */ #include "subd/subd_dice.h" +#include "subd/subd_subpatch.h" +#include "util/util_deque.h" #include "util/util_types.h" #include "util/util_vector.h" +#include <deque> + CCL_NAMESPACE_BEGIN class Mesh; class Patch; -#define DSPLIT_NON_UNIFORM -1 - class DiagSplit { - public: - vector<QuadDice::SubPatch> subpatches_quad; - vector<QuadDice::EdgeFactors> edgefactors_quad; - SubdParams params; - explicit DiagSplit(const SubdParams ¶ms); + vector<Subpatch> subpatches; + /* deque is used so that element pointers remain vaild when size is changed. */ + deque<Edge> edges; float3 to_world(Patch *patch, float2 uv); - int T(Patch *patch, float2 Pstart, float2 Pend); + int T(Patch *patch, float2 Pstart, float2 Pend, bool recursive_resolve=false); + + void limit_edge_factor(int &T, Patch *patch, float2 Pstart, float2 Pend); + void resolve_edge_factors(Subpatch &sub); + void partition_edge( Patch *patch, float2 *P, int *t0, int *t1, float2 Pstart, float2 Pend, int t); - void dispatch(QuadDice::SubPatch &sub, QuadDice::EdgeFactors &ef); - void split(QuadDice::SubPatch &sub, QuadDice::EdgeFactors &ef, int depth = 0); + void split(Subpatch &sub, int depth = 0); + + int num_alloced_verts = 0; + int alloc_verts(int n); /* Returns start index of new verts. */ + + public: + Edge *alloc_edge(); + + explicit DiagSplit(const SubdParams ¶ms); + + void split_patches(Patch *patches, size_t patches_byte_stride); + + void split_quad(const Mesh::SubdFace &face, Patch *patch); + void split_ngon(const Mesh::SubdFace &face, Patch *patches, size_t patches_byte_stride); - void split_quad(Patch *patch, QuadDice::SubPatch *subpatch = NULL); + void post_split(); }; CCL_NAMESPACE_END |