Commit: c182fe5c408c7d2580276046dce2289f8d69a2fd
Author: Mai Lavelle
Date:   Sat Jun 4 21:58:42 2016 -0400
Branches: temp-cycles-microdisplacement
https://developer.blender.org/rBc182fe5c408c7d2580276046dce2289f8d69a2fd

Add patch primitive to Mesh

Needed for subdivision and proper attribute interpolation

===================================================================

M       intern/cycles/render/mesh.cpp
M       intern/cycles/render/mesh.h

===================================================================

diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index e251556..1fc1599 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -178,6 +178,16 @@ void Mesh::reserve_curves(int numcurves, int numkeys)
        curve_attributes.resize(true);
 }
 
+void Mesh::resize_patches(int numpatches)
+{
+       patches.resize(numpatches);
+}
+
+void Mesh::reserve_patches(int numpatches)
+{
+       patches.reserve(numpatches);
+}
+
 void Mesh::clear()
 {
        /* clear all verts and triangles */
@@ -193,6 +203,8 @@ void Mesh::clear()
        curve_first_key.clear();
        curve_shader.clear();
 
+       patches.clear();
+
        attributes.clear();
        curve_attributes.clear();
        used_shaders.clear();
@@ -251,6 +263,16 @@ void Mesh::add_curve(int first_key, int shader)
        curve_shader.push_back_reserved(shader);
 }
 
+void Mesh::add_patch(int v0, int v1, int v2, int v3, int shader_, bool smooth_)
+{
+       patches.push_back_reserved({v0, v1, v2, v3, shader_, smooth_});
+}
+
+void Mesh::add_patch(int v0, int v1, int v2, int shader_, bool smooth_)
+{
+       add_patch(v0, v1, v2, -1, shader_, smooth_);
+}
+
 void Mesh::compute_bounds()
 {
        BoundBox bnds = BoundBox::empty;
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index edad6d3..a1ad3c3 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -89,6 +89,15 @@ public:
                return curve_first_key.size();
        }
 
+       /* Mesh Patch */
+       struct Patch {
+               int v[4];
+               int shader;
+               bool smooth;
+
+               bool is_quad() { return v[3] >= 0; }
+       };
+
        /* Displacement */
        enum DisplacementMethod {
                DISPLACE_BUMP = 0,
@@ -121,6 +130,8 @@ public:
        array<int> curve_first_key;
        array<int> curve_shader;
 
+       array<Patch> patches;
+
        vector<Shader*> used_shaders;
        AttributeSet attributes;
        AttributeSet curve_attributes;
@@ -154,12 +165,16 @@ public:
        void reserve_mesh(int numverts, int numfaces);
        void resize_curves(int numcurves, int numkeys);
        void reserve_curves(int numcurves, int numkeys);
+       void resize_patches(int numpatches);
+       void reserve_patches(int numpatches);
        void clear();
        void add_vertex(float3 P);
        void add_vertex_slow(float3 P);
        void add_triangle(int v0, int v1, int v2, int shader, bool smooth, bool 
forms_quad = false);
        void add_curve_key(float3 loc, float radius);
        void add_curve(int first_key, int shader);
+       void add_patch(int v0, int v1, int v2, int v3, int shader_, bool 
smooth_);
+       void add_patch(int v0, int v1, int v2, int shader_, bool smooth_);
        int split_vertex(int vertex);
 
        void compute_bounds();

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to