[Bf-blender-cvs] [3bffab7a07c] soc-2020-io-performance: Hide Nurb from Writer. Rename OBJNurbs as per object type.
Ankit Meel
noreply at git.blender.org
Wed Sep 16 13:05:51 CEST 2020
Commit: 3bffab7a07ce6d13d7e646e950f526a9160865e7
Author: Ankit Meel
Date: Tue Sep 1 14:07:38 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB3bffab7a07ce6d13d7e646e950f526a9160865e7
Hide Nurb from Writer. Rename OBJNurbs as per object type.
===================================================================
M source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
M source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
M source/blender/io/wavefront_obj/intern/obj_export_mesh.cc
M source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc
M source/blender/io/wavefront_obj/intern/obj_export_nurbs.hh
M source/blender/io/wavefront_obj/intern/obj_exporter.cc
===================================================================
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
index 2c29f98f333..dd14daf600d 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
@@ -378,22 +378,22 @@ void OBJWriter::write_loose_edges(const OBJMesh &obj_mesh_data) const
/**
* Write a NURBS curve to the OBJ file in parameter form.
*/
-void OBJWriter::write_nurbs_curve(const OBJNurbs &obj_nurbs_data) const
+void OBJWriter::write_nurbs_curve(const OBJCurve &obj_nurbs_data) const
{
- const ListBase *nurbs = obj_nurbs_data.curve_nurbs();
- LISTBASE_FOREACH (const Nurb *, nurb, nurbs) {
+ const int tot_nurbs = obj_nurbs_data.tot_nurbs();
+ for (int i = 0; i < tot_nurbs; i++) {
/* Total control points in a nurbs. */
- int tot_points = nurb->pntsv * nurb->pntsu;
+ int tot_points = obj_nurbs_data.get_nurbs_points(i);
for (int point_idx = 0; point_idx < tot_points; point_idx++) {
- float3 point_coord = obj_nurbs_data.calc_point_coords(
- *nurb, point_idx, export_params_.scaling_factor);
+ float3 point_coord = obj_nurbs_data.calc_nurbs_point_coords(
+ i, point_idx, export_params_.scaling_factor);
fprintf(outfile_, "v %f %f %f\n", point_coord[0], point_coord[1], point_coord[2]);
}
const char *nurbs_name = obj_nurbs_data.get_curve_name();
- int nurbs_degree = obj_nurbs_data.get_curve_degree(*nurb);
+ int nurbs_degree = obj_nurbs_data.get_nurbs_degree(i);
/* Number of vertices in the curve + degree of the curve if it is cyclic. */
- int curv_num = obj_nurbs_data.get_curve_num(*nurb);
+ int curv_num = obj_nurbs_data.get_nurbs_num(i);
fprintf(outfile_, "g %s\ncstype bspline\ndeg %d\n", nurbs_name, nurbs_degree);
/**
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
index a0b5e5be472..693e80ecc5a 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
+++ b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
@@ -31,7 +31,7 @@
namespace blender::io::obj {
class OBJMesh;
-class OBJNurbs;
+class OBJCurve;
/* Types of index offsets. */
enum eIndexOffsets {
@@ -84,7 +84,7 @@ class OBJWriter {
short &r_last_face_vertex_group) const;
void write_poly_elements(const OBJMesh &obj_mesh_data, Span<Vector<uint>> uv_indices);
void write_loose_edges(const OBJMesh &obj_mesh_data) const;
- void write_nurbs_curve(const OBJNurbs &obj_nurbs_data) const;
+ void write_nurbs_curve(const OBJCurve &obj_nurbs_data) const;
void update_index_offsets(const OBJMesh &obj_mesh_data);
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_mesh.cc b/source/blender/io/wavefront_obj/intern/obj_export_mesh.cc
index 41faeff75e6..dbe43df02e7 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_mesh.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_export_mesh.cc
@@ -57,7 +57,7 @@ OBJMesh::OBJMesh(Depsgraph *depsgraph, const OBJExportParams &export_params, Obj
mesh_eval_needs_free_ = false;
if (!export_mesh_eval_) {
- /* Curves and nurbs surfaces need a new mesh when they're exported in the form of vertices and
+ /* Curves and NURBS surfaces need a new mesh when they're exported in the form of vertices and
* edges.
*/
export_mesh_eval_ = BKE_mesh_new_from_object(depsgraph_, export_object_eval_, true);
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc b/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc
index 3c70ddfdf54..c5db22a8592 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc
@@ -22,6 +22,7 @@
*/
#include "BLI_float3.hh"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "DEG_depsgraph.h"
@@ -32,9 +33,10 @@
namespace blender::io::obj {
/**
- * Store NURBS curves that will be exported in parameter form, not converted to meshes.
+ * Store NURBS splines of a Curve which will be exported in parameter form,
+ * and not converted to meshes.
*/
-OBJNurbs::OBJNurbs(Depsgraph *depsgraph,
+OBJCurve::OBJCurve(Depsgraph *depsgraph,
const OBJExportParams &export_params,
Object *export_object)
: depsgraph_(depsgraph), export_object_eval_(export_object)
@@ -45,9 +47,10 @@ OBJNurbs::OBJNurbs(Depsgraph *depsgraph,
}
/**
- * Store the product of export axes settings and an object's world transform matrix.
+ * Store the product of export axes settings and an object's world transform
+ * matrix.
*/
-void OBJNurbs::store_world_axes_transform(const eTransformAxisForward forward,
+void OBJCurve::store_world_axes_transform(const eTransformAxisForward forward,
const eTransformAxisUp up)
{
float axes_transform[3][3];
@@ -60,25 +63,32 @@ void OBJNurbs::store_world_axes_transform(const eTransformAxisForward forward,
copy_v4_v4(world_axes_transform_[3], export_object_eval_->obmat[3]);
}
-const char *OBJNurbs::get_curve_name() const
+const char *OBJCurve::get_curve_name() const
{
return export_object_eval_->id.name + 2;
}
-const ListBase *OBJNurbs::curve_nurbs() const
+int OBJCurve::tot_nurbs() const
{
- return &export_curve_->nurb;
+ return BLI_listbase_count(&export_curve_->nurb);
+}
+
+int OBJCurve::get_nurbs_points(const int index) const
+{
+ const Nurb *nurb = static_cast<Nurb *>(BLI_findlink(&export_curve_->nurb, index));
+ return nurb->pntsu * nurb->pntsv;
}
/**
* Get coordinates of a vertex at given point index.
*/
-float3 OBJNurbs::calc_point_coords(const Nurb &nurb,
- const int vert_index,
- const float scaling_factor) const
+float3 OBJCurve::calc_nurbs_point_coords(const int index,
+ const int vert_index,
+ const float scaling_factor) const
{
+ const Nurb *nurb = static_cast<Nurb *>(BLI_findlink(&export_curve_->nurb, index));
float3 r_coord;
- BPoint *bpoint = nurb.bp;
+ BPoint *bpoint = nurb->bp;
bpoint += vert_index;
copy_v3_v3(r_coord, bpoint->vec);
mul_m4_v3(world_axes_transform_, r_coord);
@@ -89,13 +99,14 @@ float3 OBJNurbs::calc_point_coords(const Nurb &nurb,
/**
* Get number of "curv" points of a nurb.
*/
-int OBJNurbs::get_curve_num(const Nurb &nurb) const
+int OBJCurve::get_nurbs_num(const int index) const
{
- const int r_nurbs_degree = nurb.orderu - 1;
+ const Nurb *nurb = static_cast<Nurb *>(BLI_findlink(&export_curve_->nurb, index));
+ const int r_nurbs_degree = nurb->orderu - 1;
/* "curv_num" is the number of control points in a nurbs.
* If it is cyclic, degree also adds up. */
- int r_curv_num = nurb.pntsv * nurb.pntsu;
- if (nurb.flagu & CU_NURB_CYCLIC) {
+ int r_curv_num = nurb->pntsv * nurb->pntsu;
+ if (nurb->flagu & CU_NURB_CYCLIC) {
r_curv_num += r_nurbs_degree;
}
return r_curv_num;
@@ -104,9 +115,10 @@ int OBJNurbs::get_curve_num(const Nurb &nurb) const
/**
* Get Nurb's degree.
*/
-int OBJNurbs::get_curve_degree(const Nurb &nurb) const
+int OBJCurve::get_nurbs_degree(const int index) const
{
- return nurb.orderu - 1;
+ const Nurb *nurb = static_cast<Nurb *>(BLI_findlink(&export_curve_->nurb, index));
+ return nurb->orderu - 1;
}
} // namespace blender::io::obj
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_nurbs.hh b/source/blender/io/wavefront_obj/intern/obj_export_nurbs.hh
index 5ae8f14990a..fd2fa952107 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_nurbs.hh
+++ b/source/blender/io/wavefront_obj/intern/obj_export_nurbs.hh
@@ -28,7 +28,7 @@
#include "DNA_curve_types.h"
namespace blender::io::obj {
-class OBJNurbs : NonMovable, NonCopyable {
+class OBJCurve : NonMovable, NonCopyable {
private:
const Depsgraph *depsgraph_;
const Object *export_object_eval_;
@@ -36,15 +36,16 @@ class OBJNurbs : NonMovable, NonCopyable {
float world_axes_transform_[4][4];
public:
- OBJNurbs(Depsgraph *depsgraph, const OBJExportParams &export_params, Object *export_object);
+ OBJCurve(Depsgraph *depsgraph, const OBJExportParams &export_params, Object *export_object);
const char *get_curve_name() const;
- const ListBase *curve_nurbs() const;
- float3 calc_point_coords(const Nurb &nurb,
- const int vert_index,
- const float scaling_factor) const;
- int get_curve_num(const Nurb &nurb) const;
- int get_curve_degree(const Nurb &nurb) const;
+ int tot_nurbs() const;
+ int get_nurbs_points(const int index) const;
+ float3 calc_nurbs_point_coords(const int index,
+ const int vert_index,
+ const float scaling_factor) const;
+ int get_nurbs_num(const int index) const;
+ int get_nurbs_degree(const int index) const;
private:
void store_world_axes_transform(const eTransformAxisForward forward, const eTransformAxisUp up);
diff --git a/source/blender/io/wavefront_obj/intern/obj_exporter.cc b/source/blender/io/wavefront_obj/intern/obj_exporter.cc
index 81ae4cf5424..67f646379da 100644
--- a/source/blender/io/wavefront_obj/intern/obj_exporter.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_exporter.cc
@@ -49,7 +49,7 @@ static void find_exportable_objects(ViewLayer *view_layer,
Depsgraph *depsgraph,
const OBJExportParams &export_params,
Vector<std::unique_ptr<OBJMesh>> &r_exportable_meshes,
- Vector<std::unique_ptr<OBJNurbs>> &r_exportable_nurbs)
+ Vector<std::unique_ptr<OBJCurve>> &r_exportable_nurbs)
{
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *object_in_layer = base->object;
@@ -72,8 +72,8 @@ static void find_exportable_objects(ViewLayer *view_layer,
case CU_NURBS: {
if
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list