Blender  V2.93
subd_dice.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __SUBD_DICE_H__
18 #define __SUBD_DICE_H__
19 
20 /* DX11 like EdgeDice implementation, with different tessellation factors for
21  * each edge for watertight tessellation, with subpatch remapping to work with
22  * DiagSplit. For more algorithm details, see the DiagSplit paper or the
23  * ARB_tessellation_shader OpenGL extension, Section 2.X.2. */
24 
25 #include "util/util_types.h"
26 #include "util/util_vector.h"
27 
28 #include "subd/subd_subpatch.h"
29 
31 
32 class Camera;
33 class Mesh;
34 class Patch;
35 
36 struct SubdParams {
38  bool ptex;
39 
42  float dicing_rate;
43  int max_level;
46 
47  SubdParams(Mesh *mesh_, bool ptex_ = false)
48  {
49  mesh = mesh_;
50  ptex = ptex_;
51 
52  test_steps = 3;
53  split_threshold = 1;
54  dicing_rate = 1.0f;
55  max_level = 12;
56  camera = NULL;
57  }
58 };
59 
60 /* EdgeDice Base */
61 
62 class EdgeDice {
63  public:
67  size_t vert_offset;
68  size_t tri_offset;
69 
70  explicit EdgeDice(const SubdParams &params);
71 
72  void reserve(int num_verts, int num_triangles);
73 
74  void set_vert(Patch *patch, int index, float2 uv);
75  void add_triangle(Patch *patch, int v0, int v1, int v2);
76 
77  void stitch_triangles(Subpatch &sub, int edge);
78 };
79 
80 /* Quad EdgeDice */
81 
82 class QuadDice : public EdgeDice {
83  public:
84  explicit QuadDice(const SubdParams &params);
85 
86  float3 eval_projected(Subpatch &sub, float u, float v);
87 
88  float2 map_uv(Subpatch &sub, float u, float v);
89  void set_vert(Subpatch &sub, int index, float u, float v);
90 
91  void add_grid(Subpatch &sub, int Mu, int Mv, int offset);
92 
93  void set_side(Subpatch &sub, int edge);
94 
95  float quad_area(const float3 &a, const float3 &b, const float3 &c, const float3 &d);
96  float scale_factor(Subpatch &sub, int Mu, int Mv);
97 
98  void dice(Subpatch &sub);
99 };
100 
102 
103 #endif /* __SUBD_DICE_H__ */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
void reserve(int num_verts, int num_triangles)
Definition: subd_dice.cpp:41
void add_triangle(Patch *patch, int v0, int v1, int v2)
Definition: subd_dice.cpp:72
float3 * mesh_N
Definition: subd_dice.h:66
size_t vert_offset
Definition: subd_dice.h:67
void stitch_triangles(Subpatch &sub, int edge)
Definition: subd_dice.cpp:82
size_t tri_offset
Definition: subd_dice.h:68
float3 * mesh_P
Definition: subd_dice.h:65
SubdParams params
Definition: subd_dice.h:64
void set_vert(Patch *patch, int index, float2 uv)
Definition: subd_dice.cpp:59
EdgeDice(const SubdParams &params)
Definition: subd_dice.cpp:27
QuadDice(const SubdParams &params)
Definition: subd_dice.cpp:131
float scale_factor(Subpatch &sub, int Mu, int Mv)
Definition: subd_dice.cpp:198
float2 map_uv(Subpatch &sub, float u, float v)
Definition: subd_dice.cpp:135
void add_grid(Subpatch &sub, int Mu, int Mv, int offset)
Definition: subd_dice.cpp:227
float3 eval_projected(Subpatch &sub, float u, float v)
Definition: subd_dice.cpp:143
void set_vert(Subpatch &sub, int index, float u, float v)
Definition: subd_dice.cpp:155
void dice(Subpatch &sub)
Definition: subd_dice.cpp:253
float quad_area(const float3 &a, const float3 &b, const float3 &c, const float3 &d)
Definition: subd_dice.cpp:193
void set_side(Subpatch &sub, int edge)
Definition: subd_dice.cpp:160
#define CCL_NAMESPACE_END
static unsigned c
Definition: RandGen.cpp:97
static unsigned a[3]
Definition: RandGen.cpp:92
bool ptex
Definition: subd_dice.h:38
int max_level
Definition: subd_dice.h:43
SubdParams(Mesh *mesh_, bool ptex_=false)
Definition: subd_dice.h:47
Mesh * mesh
Definition: subd_dice.h:37
Camera * camera
Definition: subd_dice.h:44
Transform objecttoworld
Definition: subd_dice.h:45
int split_threshold
Definition: subd_dice.h:41
float dicing_rate
Definition: subd_dice.h:42
int test_steps
Definition: subd_dice.h:40