Revert "Cleanup: Replace IO orientation enum with blenlib type"
This reverts commit 074dbf08cd.
This change caused PLY and OBJ tests not to compile,
even with the identifiers updated some OBJ tests fails
with different rotation values.
This commit is contained in:
@@ -82,9 +82,8 @@ 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 = 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.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
export_params.up_axis = eIOAxis(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"));
|
||||
@@ -287,7 +286,11 @@ void WM_OT_obj_export(wmOperatorType *ot)
|
||||
INT_MIN,
|
||||
INT_MAX);
|
||||
/* Object transform options. */
|
||||
io_ui_axes_register(*ot->srna);
|
||||
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);
|
||||
RNA_def_float(
|
||||
ot->srna,
|
||||
"global_scale",
|
||||
@@ -395,9 +398,8 @@ 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 = 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.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
import_params.up_axis = eIOAxis(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");
|
||||
@@ -517,7 +519,11 @@ 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);
|
||||
io_ui_axes_register(*ot->srna);
|
||||
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);
|
||||
RNA_def_boolean(ot->srna,
|
||||
"use_split_objects",
|
||||
true,
|
||||
|
||||
@@ -71,9 +71,8 @@ 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 = 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.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
export_params.up_axis = eIOAxis(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");
|
||||
|
||||
@@ -178,7 +177,10 @@ void WM_OT_ply_export(wmOperatorType *ot)
|
||||
FILE_SORT_DEFAULT);
|
||||
|
||||
/* Object transform options. */
|
||||
io_ui_axes_register(*ot->srna);
|
||||
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);
|
||||
RNA_def_float(
|
||||
ot->srna,
|
||||
"global_scale",
|
||||
@@ -237,8 +239,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 = 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.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
params.up_axis = eIOAxis(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");
|
||||
@@ -306,7 +308,10 @@ void WM_OT_ply_import(wmOperatorType *ot)
|
||||
false,
|
||||
"Scene Unit",
|
||||
"Apply current scene's unit (as defined by unit scale) to imported data");
|
||||
io_ui_axes_register(*ot->srna);
|
||||
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);
|
||||
RNA_def_boolean(ot->srna, "merge_verts", false, "Merge Vertices", "Merges vertices by distance");
|
||||
RNA_def_enum(ot->srna,
|
||||
"import_colors",
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
# include "RNA_access.hh"
|
||||
# include "RNA_define.hh"
|
||||
|
||||
# include "IO_orientation.hh"
|
||||
# include "IO_stl.hh"
|
||||
# include "io_stl_ops.hh"
|
||||
|
||||
@@ -33,8 +32,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 = 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.forward_axis = eIOAxis(RNA_enum_get(op->ptr, "forward_axis"));
|
||||
params.up_axis = eIOAxis(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");
|
||||
@@ -121,7 +120,8 @@ void WM_OT_stl_import(wmOperatorType *ot)
|
||||
false,
|
||||
"Facet Normals",
|
||||
"Use (import) facet normals (note that this will still give flat shading)");
|
||||
io_ui_axes_register(*ot->srna);
|
||||
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", "");
|
||||
RNA_def_boolean(ot->srna,
|
||||
"use_mesh_validate",
|
||||
false,
|
||||
|
||||
@@ -4,6 +4,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
struct StructRNA;
|
||||
struct EnumPropertyItem;
|
||||
struct Main;
|
||||
struct PointerRNA;
|
||||
struct Scene;
|
||||
|
||||
void io_ui_axes_register(StructRNA &srna);
|
||||
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);
|
||||
|
||||
@@ -5,23 +5,20 @@
|
||||
#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"
|
||||
|
||||
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"},
|
||||
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"},
|
||||
{0, nullptr, 0, nullptr, nullptr}};
|
||||
|
||||
static void io_ui_forward_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
void io_ui_forward_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
{
|
||||
/* Both forward and up axes cannot be along the same direction. */
|
||||
|
||||
@@ -32,7 +29,7 @@ static void io_ui_forward_axis_update(Main * /*main*/, Scene * /*scene*/, Pointe
|
||||
}
|
||||
}
|
||||
|
||||
static void io_ui_up_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
|
||||
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");
|
||||
@@ -40,17 +37,3 @@ static void io_ui_up_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA
|
||||
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,10 +10,9 @@
|
||||
|
||||
#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,
|
||||
@@ -34,8 +33,8 @@ struct PLYExportParams {
|
||||
bool ascii_format;
|
||||
|
||||
/* Geometry Transform options. */
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
float global_scale;
|
||||
|
||||
/* File Write Options. */
|
||||
@@ -50,8 +49,8 @@ struct PLYExportParams {
|
||||
struct PLYImportParams {
|
||||
/** Full path to the source PLY file to import. */
|
||||
char filepath[FILE_MAX];
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
bool use_scene_unit;
|
||||
float global_scale;
|
||||
ePLYVertexColorMode vertex_colors;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#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"
|
||||
@@ -46,16 +45,18 @@ static Mesh *do_triangulation(const Mesh *mesh, bool force_triangulation)
|
||||
}
|
||||
|
||||
static void set_world_axes_transform(Object *object,
|
||||
const math::AxisSigned forward,
|
||||
const math::AxisSigned up,
|
||||
const eIOAxis forward,
|
||||
const eIOAxis up,
|
||||
float r_world_and_axes_transform[4][4],
|
||||
float r_world_and_axes_normal_transform[3][3])
|
||||
{
|
||||
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);
|
||||
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);
|
||||
/* 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.ptr(), object->object_to_world[3]);
|
||||
mul_v3_m3v3(r_world_and_axes_transform[3], axes_transform, 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,7 +17,6 @@
|
||||
#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"
|
||||
@@ -228,14 +227,14 @@ void importer_main(Main *bmain,
|
||||
global_scale *= scene->unit.scale_length;
|
||||
}
|
||||
float scale_vec[3] = {global_scale, global_scale, global_scale};
|
||||
|
||||
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 obmat3x3[3][3];
|
||||
unit_m3(obmat3x3);
|
||||
float obmat4x4[4][4];
|
||||
unit_m4(obmat4x4);
|
||||
copy_m4_m3(obmat4x4, axes_transform.ptr());
|
||||
/* +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);
|
||||
rescale_m4(obmat4x4, scale_vec);
|
||||
BKE_object_apply_mat4(obj, obmat4x4, true, false);
|
||||
|
||||
|
||||
@@ -9,15 +9,14 @@
|
||||
#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];
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
bool use_facet_normal;
|
||||
bool use_scene_unit;
|
||||
float global_scale;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#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"
|
||||
@@ -116,14 +115,14 @@ void importer_main(Main *bmain,
|
||||
global_scale *= scene->unit.scale_length;
|
||||
}
|
||||
float scale_vec[3] = {global_scale, global_scale, global_scale};
|
||||
|
||||
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 obmat3x3[3][3];
|
||||
unit_m3(obmat3x3);
|
||||
float obmat4x4[4][4];
|
||||
unit_m4(obmat4x4);
|
||||
copy_m4_m3(obmat4x4, axes_transform.ptr());
|
||||
/* +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);
|
||||
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. */
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
float global_scale;
|
||||
|
||||
/* File Write Options. */
|
||||
@@ -67,8 +67,8 @@ struct OBJImportParams {
|
||||
/** Value 0 disables clamping. */
|
||||
float clamp_size;
|
||||
float global_scale;
|
||||
blender::math::AxisSigned forward_axis;
|
||||
blender::math::AxisSigned up_axis;
|
||||
eIOAxis forward_axis;
|
||||
eIOAxis up_axis;
|
||||
bool use_split_objects;
|
||||
bool use_split_groups;
|
||||
bool import_vertex_groups;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#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"
|
||||
|
||||
@@ -135,15 +134,16 @@ void OBJMesh::triangulate_mesh_eval()
|
||||
this->set_mesh(triangulated);
|
||||
}
|
||||
|
||||
void OBJMesh::set_world_axes_transform(const math::AxisSigned forward, const math::AxisSigned up)
|
||||
void OBJMesh::set_world_axes_transform(const eIOAxis forward, const eIOAxis up)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
/* mul_m4_m3m4 does not transform last row of obmat, i.e. location data. */
|
||||
mul_v3_m3v3(
|
||||
world_and_axes_transform_[3], axes_transform.ptr(), export_object_eval_.object_to_world[3]);
|
||||
world_and_axes_transform_[3], axes_transform, 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(math::AxisSigned forward, math::AxisSigned up);
|
||||
void set_world_axes_transform(eIOAxis forward, eIOAxis up);
|
||||
};
|
||||
} // namespace blender::io::obj
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#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"
|
||||
@@ -30,14 +29,15 @@ OBJCurve::OBJCurve(const Depsgraph *depsgraph,
|
||||
set_world_axes_transform(export_params.forward_axis, export_params.up_axis);
|
||||
}
|
||||
|
||||
void OBJCurve::set_world_axes_transform(const math::AxisSigned forward, const math::AxisSigned up)
|
||||
void OBJCurve::set_world_axes_transform(const eIOAxis forward, const eIOAxis up)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
/* #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.ptr(), export_object_eval_->object_to_world[3]);
|
||||
mul_v3_m3v3(world_axes_transform_[3], axes_transform, 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(math::AxisSigned forward, math::AxisSigned up);
|
||||
void set_world_axes_transform(eIOAxis forward, eIOAxis up);
|
||||
};
|
||||
|
||||
} // namespace blender::io::obj
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#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"
|
||||
@@ -100,12 +99,14 @@ Vector<Vector<int>> fixup_invalid_polygon(Span<float3> vertex_coords,
|
||||
|
||||
void transform_object(Object *object, const OBJImportParams &import_params)
|
||||
{
|
||||
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 axes_transform[3][3];
|
||||
unit_m3(axes_transform);
|
||||
float obmat[4][4];
|
||||
unit_m4(obmat);
|
||||
copy_m4_m3(obmat, axes_transform.ptr());
|
||||
/* +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);
|
||||
|
||||
float scale_vec[3] = {
|
||||
import_params.global_scale, import_params.global_scale, import_params.global_scale};
|
||||
|
||||
Reference in New Issue
Block a user