Cleanup: Replace IO orientation enum with blenlib type
This helps to document standard behavior, improves type safety, reduces code duplication, and gets us closer to being able to remove some of the older C math API.
This commit is contained in:
@@ -82,8 +82,9 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
|
||||
export_params.start_frame = RNA_int_get(op->ptr, "start_frame");
|
||||
export_params.end_frame = RNA_int_get(op->ptr, "end_frame");
|
||||
|
||||
export_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
export_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
|
||||
export_params.forward_axis = blender::math::AxisSigned::from_int(
|
||||
RNA_enum_get(op->ptr, "forward_axis"));
|
||||
export_params.up_axis = blender::math::AxisSigned::from_int(RNA_enum_get(op->ptr, "up_axis"));
|
||||
export_params.global_scale = RNA_float_get(op->ptr, "global_scale");
|
||||
export_params.apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
||||
export_params.export_eval_mode = eEvaluationMode(RNA_enum_get(op->ptr, "export_eval_mode"));
|
||||
@@ -286,11 +287,7 @@ void WM_OT_obj_export(wmOperatorType *ot)
|
||||
INT_MIN,
|
||||
INT_MAX);
|
||||
/* Object transform options. */
|
||||
prop = RNA_def_enum(
|
||||
ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
|
||||
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
|
||||
io_ui_axes_register(*ot->srna);
|
||||
RNA_def_float(
|
||||
ot->srna,
|
||||
"global_scale",
|
||||
@@ -398,8 +395,9 @@ static int wm_obj_import_exec(bContext *C, wmOperator *op)
|
||||
RNA_string_get(op->ptr, "filepath", import_params.filepath);
|
||||
import_params.global_scale = RNA_float_get(op->ptr, "global_scale");
|
||||
import_params.clamp_size = RNA_float_get(op->ptr, "clamp_size");
|
||||
import_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
import_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
|
||||
import_params.forward_axis = blender::math::AxisSigned::from_int(
|
||||
RNA_enum_get(op->ptr, "forward_axis"));
|
||||
import_params.up_axis = blender::math::AxisSigned::from_int(RNA_enum_get(op->ptr, "up_axis"));
|
||||
import_params.use_split_objects = RNA_boolean_get(op->ptr, "use_split_objects");
|
||||
import_params.use_split_groups = RNA_boolean_get(op->ptr, "use_split_groups");
|
||||
import_params.import_vertex_groups = RNA_boolean_get(op->ptr, "import_vertex_groups");
|
||||
@@ -519,11 +517,7 @@ void WM_OT_obj_import(wmOperatorType *ot)
|
||||
"Resize the objects to keep bounding box under this value. Value 0 disables clamping",
|
||||
0.0f,
|
||||
1000.0f);
|
||||
prop = RNA_def_enum(
|
||||
ot->srna, "forward_axis", io_transform_axis, IO_AXIS_NEGATIVE_Z, "Forward Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
|
||||
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Y, "Up Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
|
||||
io_ui_axes_register(*ot->srna);
|
||||
RNA_def_boolean(ot->srna,
|
||||
"use_split_objects",
|
||||
true,
|
||||
|
||||
@@ -71,8 +71,9 @@ static int wm_ply_export_exec(bContext *C, wmOperator *op)
|
||||
RNA_string_get(op->ptr, "filepath", export_params.filepath);
|
||||
export_params.blen_filepath = CTX_data_main(C)->filepath;
|
||||
|
||||
export_params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
export_params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
|
||||
export_params.forward_axis = blender::math::AxisSigned::from_int(
|
||||
RNA_enum_get(op->ptr, "forward_axis"));
|
||||
export_params.up_axis = blender::math::AxisSigned::from_int(RNA_enum_get(op->ptr, "up_axis"));
|
||||
export_params.global_scale = RNA_float_get(op->ptr, "global_scale");
|
||||
export_params.apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
|
||||
|
||||
@@ -177,10 +178,7 @@ void WM_OT_ply_export(wmOperatorType *ot)
|
||||
FILE_SORT_DEFAULT);
|
||||
|
||||
/* Object transform options. */
|
||||
prop = RNA_def_enum(ot->srna, "forward_axis", io_transform_axis, IO_AXIS_Y, "Forward Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
|
||||
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Z, "Up Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
|
||||
io_ui_axes_register(*ot->srna);
|
||||
RNA_def_float(
|
||||
ot->srna,
|
||||
"global_scale",
|
||||
@@ -239,8 +237,8 @@ static int wm_ply_import_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
static int wm_ply_import_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
PLYImportParams params{};
|
||||
params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
|
||||
params.forward_axis = blender::math::AxisSigned::from_int(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
params.up_axis = blender::math::AxisSigned::from_int(RNA_enum_get(op->ptr, "up_axis"));
|
||||
params.use_scene_unit = RNA_boolean_get(op->ptr, "use_scene_unit");
|
||||
params.global_scale = RNA_float_get(op->ptr, "global_scale");
|
||||
params.merge_verts = RNA_boolean_get(op->ptr, "merge_verts");
|
||||
@@ -308,10 +306,7 @@ void WM_OT_ply_import(wmOperatorType *ot)
|
||||
false,
|
||||
"Scene Unit",
|
||||
"Apply current scene's unit (as defined by unit scale) to imported data");
|
||||
prop = RNA_def_enum(ot->srna, "forward_axis", io_transform_axis, IO_AXIS_Y, "Forward Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_forward_axis_update);
|
||||
prop = RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Z, "Up Axis", "");
|
||||
RNA_def_property_update_runtime(prop, io_ui_up_axis_update);
|
||||
io_ui_axes_register(*ot->srna);
|
||||
RNA_def_boolean(ot->srna, "merge_verts", false, "Merge Vertices", "Merges vertices by distance");
|
||||
RNA_def_enum(ot->srna,
|
||||
"import_colors",
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
# include "RNA_access.hh"
|
||||
# include "RNA_define.hh"
|
||||
|
||||
# include "IO_orientation.hh"
|
||||
# include "IO_stl.hh"
|
||||
# include "io_stl_ops.hh"
|
||||
|
||||
@@ -32,8 +33,8 @@ static int wm_stl_import_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
||||
static int wm_stl_import_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
STLImportParams params{};
|
||||
params.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
params.up_axis = eIOAxis(RNA_enum_get(op->ptr, "up_axis"));
|
||||
params.forward_axis = blender::math::AxisSigned::from_int(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
params.up_axis = blender::math::AxisSigned::from_int(RNA_enum_get(op->ptr, "up_axis"));
|
||||
params.use_facet_normal = RNA_boolean_get(op->ptr, "use_facet_normal");
|
||||
params.use_scene_unit = RNA_boolean_get(op->ptr, "use_scene_unit");
|
||||
params.global_scale = RNA_float_get(op->ptr, "global_scale");
|
||||
@@ -120,8 +121,7 @@ void WM_OT_stl_import(wmOperatorType *ot)
|
||||
false,
|
||||
"Facet Normals",
|
||||
"Use (import) facet normals (note that this will still give flat shading)");
|
||||
RNA_def_enum(ot->srna, "forward_axis", io_transform_axis, IO_AXIS_Y, "Forward Axis", "");
|
||||
RNA_def_enum(ot->srna, "up_axis", io_transform_axis, IO_AXIS_Z, "Up Axis", "");
|
||||
io_ui_axes_register(*ot->srna);
|
||||
RNA_def_boolean(ot->srna,
|
||||
"use_mesh_validate",
|
||||
false,
|
||||
|
||||
@@ -4,21 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
struct EnumPropertyItem;
|
||||
struct Main;
|
||||
struct PointerRNA;
|
||||
struct Scene;
|
||||
struct StructRNA;
|
||||
|
||||
enum eIOAxis {
|
||||
IO_AXIS_X = 0,
|
||||
IO_AXIS_Y = 1,
|
||||
IO_AXIS_Z = 2,
|
||||
IO_AXIS_NEGATIVE_X = 3,
|
||||
IO_AXIS_NEGATIVE_Y = 4,
|
||||
IO_AXIS_NEGATIVE_Z = 5,
|
||||
};
|
||||
|
||||
extern const EnumPropertyItem io_transform_axis[];
|
||||
|
||||
void io_ui_forward_axis_update(Main *main, Scene *scene, PointerRNA *ptr);
|
||||
void io_ui_up_axis_update(Main *main, Scene *scene, PointerRNA *ptr);
|
||||
void io_ui_axes_register(StructRNA &srna);
|
||||
|
||||
@@ -5,20 +5,23 @@
|
||||
#include "BKE_main.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_define.hh"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
#include "BLI_math_basis_types.hh"
|
||||
|
||||
#include "IO_orientation.hh"
|
||||
|
||||
const EnumPropertyItem io_transform_axis[] = {
|
||||
{IO_AXIS_X, "X", 0, "X", "Positive X axis"},
|
||||
{IO_AXIS_Y, "Y", 0, "Y", "Positive Y axis"},
|
||||
{IO_AXIS_Z, "Z", 0, "Z", "Positive Z axis"},
|
||||
{IO_AXIS_NEGATIVE_X, "NEGATIVE_X", 0, "-X", "Negative X axis"},
|
||||
{IO_AXIS_NEGATIVE_Y, "NEGATIVE_Y", 0, "-Y", "Negative Y axis"},
|
||||
{IO_AXIS_NEGATIVE_Z, "NEGATIVE_Z", 0, "-Z", "Negative Z axis"},
|
||||
static const EnumPropertyItem io_transform_axis[] = {
|
||||
{int(blender::math::AxisSigned::X_POS), "X", 0, "X", "Positive X axis"},
|
||||
{int(blender::math::AxisSigned::Y_POS), "Y", 0, "Y", "Positive Y axis"},
|
||||
{int(blender::math::AxisSigned::Z_POS), "Z", 0, "Z", "Positive Z axis"},
|
||||
{int(blender::math::AxisSigned::X_NEG), "NEGATIVE_X", 0, "-X", "Negative X axis"},
|
||||
{int(blender::math::AxisSigned::Y_NEG), "NEGATIVE_Y", 0, "-Y", "Negative Y axis"},
|
||||
{int(blender::math::AxisSigned::Z_NEG), "NEGATIVE_Z", 0, "-Z", "Negative Z axis"},
|
||||
{0, nullptr, 0, nullptr, nullptr}};
|
||||
|
||||
void io_ui_forward_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
static void io_ui_forward_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
{
|
||||
/* Both forward and up axes cannot be along the same direction. */
|
||||
|
||||
@@ -29,7 +32,7 @@ void io_ui_forward_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *p
|
||||
}
|
||||
}
|
||||
|
||||
void io_ui_up_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
static void io_ui_up_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
{
|
||||
int forward = RNA_enum_get(ptr, "forward_axis");
|
||||
int up = RNA_enum_get(ptr, "up_axis");
|
||||
@@ -37,3 +40,17 @@ void io_ui_up_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
RNA_enum_set(ptr, "forward_axis", (forward + 1) % 6);
|
||||
}
|
||||
}
|
||||
|
||||
void io_ui_axes_register(StructRNA &srna)
|
||||
{
|
||||
PropertyRNA *forward = RNA_def_enum(&srna,
|
||||
"forward_axis",
|
||||
io_transform_axis,
|
||||
int(blender::math::AxisSigned::Y_POS),
|
||||
"Forward Axis",
|
||||
"");
|
||||
RNA_def_property_update_runtime(forward, io_ui_forward_axis_update);
|
||||
PropertyRNA *up = RNA_def_enum(
|
||||
&srna, "up_axis", io_transform_axis, int(blender::math::AxisSigned::Z_POS), "Up Axis", "");
|
||||
RNA_def_property_update_runtime(up, io_ui_up_axis_update);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "BLI_math_basis_types.hh"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "DNA_windowmanager_types.h"
|
||||
#include "IO_orientation.hh"
|
||||
|
||||
enum ePLYVertexColorMode {
|
||||
PLY_VERTEX_COLOR_NONE = 0,
|
||||
@@ -33,8 +34,8 @@ struct PLYExportParams {
|
||||
bool ascii_format;
|
||||
|
||||
/* Geometry Transform options. */
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
float global_scale;
|
||||
|
||||
/* File Write Options. */
|
||||
@@ -49,8 +50,8 @@ struct PLYExportParams {
|
||||
struct PLYImportParams {
|
||||
/** Full path to the source PLY file to import. */
|
||||
char filepath[FILE_MAX];
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
bool use_scene_unit;
|
||||
float global_scale;
|
||||
ePLYVertexColorMode vertex_colors;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "BLI_hash.hh"
|
||||
#include "BLI_math_color.hh"
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_vector.hh"
|
||||
@@ -45,18 +46,16 @@ static Mesh *do_triangulation(const Mesh *mesh, bool force_triangulation)
|
||||
}
|
||||
|
||||
static void set_world_axes_transform(Object *object,
|
||||
const eIOAxis forward,
|
||||
const eIOAxis up,
|
||||
const math::AxisSigned forward,
|
||||
const math::AxisSigned up,
|
||||
float r_world_and_axes_transform[4][4],
|
||||
float r_world_and_axes_normal_transform[3][3])
|
||||
{
|
||||
float axes_transform[3][3];
|
||||
unit_m3(axes_transform);
|
||||
/* +Y-forward and +Z-up are the default Blender axis settings. */
|
||||
mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform);
|
||||
mul_m4_m3m4(r_world_and_axes_transform, axes_transform, object->object_to_world);
|
||||
const math::CartesianBasis basis = math::from_orthonormal_axes(forward, up);
|
||||
const float3x3 axes_transform = math::from_rotation<float3x3>(basis);
|
||||
mul_m4_m3m4(r_world_and_axes_transform, axes_transform.ptr(), object->object_to_world);
|
||||
/* mul_m4_m3m4 does not transform last row of obmat, i.e. location data. */
|
||||
mul_v3_m3v3(r_world_and_axes_transform[3], axes_transform, object->object_to_world[3]);
|
||||
mul_v3_m3v3(r_world_and_axes_transform[3], axes_transform.ptr(), object->object_to_world[3]);
|
||||
r_world_and_axes_transform[3][3] = object->object_to_world[3][3];
|
||||
|
||||
/* Normals need inverse transpose of the regular matrix to handle non-uniform scale. */
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_memory_utils.hh"
|
||||
@@ -227,14 +228,14 @@ void importer_main(Main *bmain,
|
||||
global_scale *= scene->unit.scale_length;
|
||||
}
|
||||
float scale_vec[3] = {global_scale, global_scale, global_scale};
|
||||
float obmat3x3[3][3];
|
||||
unit_m3(obmat3x3);
|
||||
|
||||
const math::CartesianBasis basis = math::from_orthonormal_axes(import_params.forward_axis,
|
||||
import_params.up_axis);
|
||||
const float3x3 axes_transform = math::from_rotation<float3x3>(basis);
|
||||
|
||||
float obmat4x4[4][4];
|
||||
unit_m4(obmat4x4);
|
||||
/* +Y-forward and +Z-up are the Blender's default axis settings. */
|
||||
mat3_from_axis_conversion(
|
||||
IO_AXIS_Y, IO_AXIS_Z, import_params.forward_axis, import_params.up_axis, obmat3x3);
|
||||
copy_m4_m3(obmat4x4, obmat3x3);
|
||||
copy_m4_m3(obmat4x4, axes_transform.ptr());
|
||||
rescale_m4(obmat4x4, scale_vec);
|
||||
BKE_object_apply_mat4(obj, obmat4x4, true, false);
|
||||
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "BLI_math_basis_types.hh"
|
||||
#include "BLI_path_util.h"
|
||||
#include "IO_orientation.hh"
|
||||
|
||||
struct STLImportParams {
|
||||
/** Full path to the source STL file to import. */
|
||||
char filepath[FILE_MAX];
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
bool use_facet_normal;
|
||||
bool use_scene_unit;
|
||||
float global_scale;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "BLI_fileops.hh"
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_memory_utils.hh"
|
||||
@@ -115,14 +116,14 @@ void importer_main(Main *bmain,
|
||||
global_scale *= scene->unit.scale_length;
|
||||
}
|
||||
float scale_vec[3] = {global_scale, global_scale, global_scale};
|
||||
float obmat3x3[3][3];
|
||||
unit_m3(obmat3x3);
|
||||
|
||||
const math::CartesianBasis basis = math::from_orthonormal_axes(import_params.forward_axis,
|
||||
import_params.up_axis);
|
||||
const float3x3 axes_transform = math::from_rotation<float3x3>(basis);
|
||||
|
||||
float obmat4x4[4][4];
|
||||
unit_m4(obmat4x4);
|
||||
/* +Y-forward and +Z-up are the Blender's default axis settings. */
|
||||
mat3_from_axis_conversion(
|
||||
IO_AXIS_Y, IO_AXIS_Z, import_params.forward_axis, import_params.up_axis, obmat3x3);
|
||||
copy_m4_m3(obmat4x4, obmat3x3);
|
||||
copy_m4_m3(obmat4x4, axes_transform.ptr());
|
||||
rescale_m4(obmat4x4, scale_vec);
|
||||
BKE_object_apply_mat4(obj, obmat4x4, true, false);
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_math_basis_types.hh"
|
||||
#include "BLI_path_util.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
#include "IO_orientation.hh"
|
||||
#include "IO_path_util_types.hh"
|
||||
|
||||
struct OBJExportParams {
|
||||
@@ -34,8 +34,8 @@ struct OBJExportParams {
|
||||
int end_frame;
|
||||
|
||||
/* Geometry Transform options. */
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
float global_scale;
|
||||
|
||||
/* File Write Options. */
|
||||
@@ -67,8 +67,8 @@ struct OBJImportParams {
|
||||
/** Value 0 disables clamping. */
|
||||
float clamp_size;
|
||||
float global_scale;
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
bool use_split_objects;
|
||||
bool use_split_groups;
|
||||
bool import_vertex_groups;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "BKE_mesh_mapping.hh"
|
||||
#include "BKE_object.h"
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
@@ -134,16 +135,15 @@ void OBJMesh::triangulate_mesh_eval()
|
||||
this->set_mesh(triangulated);
|
||||
}
|
||||
|
||||
void OBJMesh::set_world_axes_transform(const eIOAxis forward, const eIOAxis up)
|
||||
void OBJMesh::set_world_axes_transform(const math::AxisSigned forward, const math::AxisSigned up)
|
||||
{
|
||||
float axes_transform[3][3];
|
||||
unit_m3(axes_transform);
|
||||
/* +Y-forward and +Z-up are the default Blender axis settings. */
|
||||
mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform);
|
||||
mul_m4_m3m4(world_and_axes_transform_, axes_transform, export_object_eval_.object_to_world);
|
||||
const math::CartesianBasis basis = math::from_orthonormal_axes(forward, up);
|
||||
const float3x3 axes_transform = math::from_rotation<float3x3>(basis);
|
||||
mul_m4_m3m4(
|
||||
world_and_axes_transform_, axes_transform.ptr(), export_object_eval_.object_to_world);
|
||||
/* mul_m4_m3m4 does not transform last row of obmat, i.e. location data. */
|
||||
mul_v3_m3v3(
|
||||
world_and_axes_transform_[3], axes_transform, export_object_eval_.object_to_world[3]);
|
||||
world_and_axes_transform_[3], axes_transform.ptr(), export_object_eval_.object_to_world[3]);
|
||||
world_and_axes_transform_[3][3] = export_object_eval_.object_to_world[3][3];
|
||||
|
||||
/* Normals need inverse transpose of the regular matrix to handle non-uniform scale. */
|
||||
|
||||
@@ -234,6 +234,6 @@ class OBJMesh : NonCopyable {
|
||||
/**
|
||||
* Set the final transform after applying axes settings and an Object's world transform.
|
||||
*/
|
||||
void set_world_axes_transform(eIOAxis forward, eIOAxis up);
|
||||
void set_world_axes_transform(math::AxisSigned forward, math::AxisSigned up);
|
||||
};
|
||||
} // namespace blender::io::obj
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_math_vector_types.hh"
|
||||
@@ -29,15 +30,14 @@ OBJCurve::OBJCurve(const Depsgraph *depsgraph,
|
||||
set_world_axes_transform(export_params.forward_axis, export_params.up_axis);
|
||||
}
|
||||
|
||||
void OBJCurve::set_world_axes_transform(const eIOAxis forward, const eIOAxis up)
|
||||
void OBJCurve::set_world_axes_transform(const math::AxisSigned forward, const math::AxisSigned up)
|
||||
{
|
||||
float axes_transform[3][3];
|
||||
unit_m3(axes_transform);
|
||||
/* +Y-forward and +Z-up are the Blender's default axis settings. */
|
||||
mat3_from_axis_conversion(forward, up, IO_AXIS_Y, IO_AXIS_Z, axes_transform);
|
||||
mul_m4_m3m4(world_axes_transform_, axes_transform, export_object_eval_->object_to_world);
|
||||
const math::CartesianBasis basis = math::from_orthonormal_axes(forward, up);
|
||||
const float3x3 axes_transform = math::from_rotation<float3x3>(basis);
|
||||
mul_m4_m3m4(world_axes_transform_, axes_transform.ptr(), export_object_eval_->object_to_world);
|
||||
/* #mul_m4_m3m4 does not transform last row of #Object.object_to_world, i.e. location data. */
|
||||
mul_v3_m3v3(world_axes_transform_[3], axes_transform, export_object_eval_->object_to_world[3]);
|
||||
mul_v3_m3v3(
|
||||
world_axes_transform_[3], axes_transform.ptr(), export_object_eval_->object_to_world[3]);
|
||||
world_axes_transform_[3][3] = export_object_eval_->object_to_world[3][3];
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ class OBJCurve : NonCopyable {
|
||||
/**
|
||||
* Set the final transform after applying axes settings and an Object's world transform.
|
||||
*/
|
||||
void set_world_axes_transform(eIOAxis forward, eIOAxis up);
|
||||
void set_world_axes_transform(math::AxisSigned forward, math::AxisSigned up);
|
||||
};
|
||||
|
||||
} // namespace blender::io::obj
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "BLI_delaunay_2d.h"
|
||||
#include "BLI_math_geom.h"
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_matrix.hh"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_set.hh"
|
||||
@@ -99,14 +100,12 @@ Vector<Vector<int>> fixup_invalid_polygon(Span<float3> vertex_coords,
|
||||
|
||||
void transform_object(Object *object, const OBJImportParams &import_params)
|
||||
{
|
||||
float axes_transform[3][3];
|
||||
unit_m3(axes_transform);
|
||||
const math::CartesianBasis basis = math::from_orthonormal_axes(import_params.forward_axis,
|
||||
import_params.up_axis);
|
||||
const float3x3 axes_transform = math::from_rotation<float3x3>(basis);
|
||||
float obmat[4][4];
|
||||
unit_m4(obmat);
|
||||
/* +Y-forward and +Z-up are the default Blender axis settings. */
|
||||
mat3_from_axis_conversion(
|
||||
IO_AXIS_Y, IO_AXIS_Z, import_params.forward_axis, import_params.up_axis, axes_transform);
|
||||
copy_m4_m3(obmat, axes_transform);
|
||||
copy_m4_m3(obmat, axes_transform.ptr());
|
||||
|
||||
float scale_vec[3] = {
|
||||
import_params.global_scale, import_params.global_scale, import_params.global_scale};
|
||||
|
||||
Reference in New Issue
Block a user