diff options
Diffstat (limited to 'intern/cycles/render/mesh.h')
-rw-r--r-- | intern/cycles/render/mesh.h | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h index 557b664bff3..edad6d32f00 100644 --- a/intern/cycles/render/mesh.h +++ b/intern/cycles/render/mesh.h @@ -18,6 +18,7 @@ #define __MESH_H__ #include "attribute.h" +#include "node.h" #include "shader.h" #include "util_boundbox.h" @@ -42,8 +43,10 @@ class DiagSplit; /* Mesh */ -class Mesh { +class Mesh : public Node { public: + NODE_DECLARE; + /* Mesh Triangle */ struct Triangle { int v[3]; @@ -51,17 +54,41 @@ public: void bounds_grow(const float3 *verts, BoundBox& bounds) const; }; + Triangle get_triangle(size_t i) const + { + Triangle tri = {{triangles[i*3 + 0], triangles[i*3 + 1], triangles[i*3 + 2]}}; + return tri; + } + + size_t num_triangles() const + { + return triangles.size() / 3; + } + /* Mesh Curve */ struct Curve { int first_key; int num_keys; - uint shader; int num_segments() { return num_keys - 1; } - void bounds_grow(const int k, const float4 *curve_keys, BoundBox& bounds) const; + void bounds_grow(const int k, const float3 *curve_keys, const float *curve_radius, BoundBox& bounds) const; }; + Curve get_curve(size_t i) const + { + int first = curve_first_key[i]; + int next_first = (i+1 < curve_first_key.size()) ? curve_first_key[i+1] : curve_keys.size(); + + Curve curve = {first, next_first - first}; + return curve; + } + + size_t num_curves() const + { + return curve_first_key.size(); + } + /* Displacement */ enum DisplacementMethod { DISPLACE_BUMP = 0, @@ -71,8 +98,6 @@ public: DISPLACE_NUM_METHODS, }; - ustring name; - /* Mesh Data */ enum GeometryFlags { GEOMETRY_NONE = 0, @@ -82,17 +107,19 @@ public: int geometry_flags; /* used to distinguish meshes with no verts and meshed for which geometry is not created */ - vector<float3> verts; - vector<Triangle> triangles; - vector<uint> shader; - vector<bool> smooth; - vector<bool> forms_quad; /* used to tell if triangle is part of a quad patch */ + array<int> triangles; + array<float3> verts; + array<int> shader; + array<bool> smooth; + array<bool> forms_quad; /* used to tell if triangle is part of a quad patch */ bool has_volume; /* Set in the device_update_flags(). */ bool has_surface_bssrdf; /* Set in the device_update_flags(). */ - vector<float4> curve_keys; /* co + radius */ - vector<Curve> curves; + array<float3> curve_keys; + array<float> curve_radius; + array<int> curve_first_key; + array<int> curve_shader; vector<Shader*> used_shaders; AttributeSet attributes; @@ -123,12 +150,16 @@ public: Mesh(); ~Mesh(); - void reserve(int numverts, int numfaces, int numcurves, int numcurvekeys); + void resize_mesh(int numverts, int numfaces); + void reserve_mesh(int numverts, int numfaces); + void resize_curves(int numcurves, int numkeys); + void reserve_curves(int numcurves, int numkeys); void clear(); - void set_triangle(int i, int v0, int v1, int v2, int shader, bool smooth, bool forms_quad = false); + 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 num_keys, int shader); + void add_curve(int first_key, int shader); int split_vertex(int vertex); void compute_bounds(); |