Blender V5.0
subd/split.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7/* DiagSplit: Parallel, Crack-free, Adaptive Tessellation for Micro-polygon Rendering
8 * Splits up patches and determines edge tessellation factors for dicing. Patch
9 * evaluation at arbitrary points is required for this to work. See the paper
10 * for more details. */
11
12#include "scene/mesh.h"
13
14#include "subd/dice.h"
15#include "subd/subpatch.h"
16
17#include "util/set.h"
18#include "util/types.h"
19#include "util/vector.h"
20
22
23class Mesh;
24class Patch;
26
27class DiagSplit {
28 private:
29 SubdParams params;
30 vector<SubPatch> subpatches;
31 vector<bool> owned_verts;
32 unordered_set<SubEdge, SubEdge::Hash, SubEdge::Equal> edges;
33 int num_verts = 0;
34 int num_triangles = 0;
35
36 /* Allocate vertices, edges and subpatches. */
37 int alloc_verts(const int num);
38 SubEdge *alloc_edge(const int v0, const int v1, const int depth, bool &was_missing);
39 void alloc_edge(SubPatch::Edge *sub_edge,
40 const int v0,
41 const int v1,
42 const int depth,
43 const bool want_to_own_edge,
44 const bool want_to_own_vertex);
45 void alloc_subpatch(SubPatch &&sub);
46
47 /* Compute edge factors. */
48 float3 to_world(const Patch *patch, const float2 uv);
49 std::pair<int, float> T(const Patch *patch,
50 const float2 uv_start,
51 const float2 uv_end,
52 const int depth,
53 const bool recursive_resolve = false);
54 int limit_edge_factor(const Patch *patch,
55 const float2 uv_start,
56 const float2 uv_end,
57 const int T);
58 void assign_edge_factor(SubEdge *edge,
59 const Patch *patch,
60 const float2 uv_start,
61 const float2 uv_end,
62 const bool recursive_resolve = false);
63 void resolve_edge_factors(const SubPatch &sub);
64
65 /* Split edge, subpatch, quad and n-gon. */
66 float2 split_edge(const Patch *patch,
67 SubPatch::Edge *subedge,
68 SubPatch::Edge *subedge_a,
69 SubPatch::Edge *subedge_b,
70 float2 uv_start,
71 float2 uv_end);
72 void split_quad(SubPatch &&sub);
73 void split_triangle(SubPatch &&sub);
74 void split_quad_into_triangles(SubPatch &&sub);
75 void split_quad(const Mesh::SubdFace &face, const int face_index, const Patch *patch);
76 void split_ngon(const Mesh::SubdFace &face,
77 const int face_index,
78 const Patch *patches,
79 const size_t patches_byte_stride);
80
81 public:
82 explicit DiagSplit(const SubdParams &params);
83
84 void split_patches(const Patch *patches, const size_t patches_byte_stride);
85
86 size_t get_num_subpatches() const
87 {
88 return subpatches.size();
89 }
90
91 const SubPatch &get_subpatch(const size_t i) const
92 {
93 return subpatches[i];
94 }
95
96 int get_num_verts() const
97 {
98 return num_verts;
99 }
100
102 {
103 return num_triangles;
104 }
105};
106
ATTR_WARN_UNUSED_RESULT const size_t num
DiagSplit(const SubdParams &params)
int get_num_triangles() const
Definition subd/split.h:101
int get_num_verts() const
Definition subd/split.h:96
const SubPatch & get_subpatch(const size_t i) const
Definition subd/split.h:91
size_t get_num_subpatches() const
Definition subd/split.h:86
void split_patches(const Patch *patches, const size_t patches_byte_stride)
Definition patch.h:12
#define CCL_NAMESPACE_END
#define T
i
Definition text_draw.cc:230