9#include "COLLADAFWMeshVertexData.h"
10#include "COLLADAFWNode.h"
74 if (index >=
array.getValuesCount()) {
78 if (
array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT) {
79 return array.getFloatValues()->getData()[index];
82 return array.getDoubleValues()->getData()[index];
106 if (cti ==
nullptr) {
131 const bool xmirror =
false;
132 const bool keep_transform =
false;
134 if (par && is_parent_space) {
136 par->object_to_world().ptr(),
137 ob->object_to_world().ptr());
141 nullptr,
C, scene, ob, par, partype, xmirror, keep_transform,
nullptr);
147 std::vector<bAction *> actions;
156 actions.push_back(act);
161 actions.push_back(action);
168 const std::string &ob_name,
169 const std::string &channel_type,
170 const std::string &axis_name,
171 const std::string &axis_separator)
173 std::string
result = action_name +
"_" + channel_type;
174 if (ob_name.length() > 0) {
177 if (axis_name.length() > 0) {
178 result += axis_separator + axis_name;
217 if (!node_extra_tags) {
222 std::vector<std::string> collection_names = node_extra_tags->
dataSplitString(
"collections");
223 std::vector<std::string> visible_names = node_extra_tags->
dataSplitString(
"visible_collections");
224 std::set<std::string> visible_names_set(visible_names.begin(), visible_names.end());
225 for (
const std::string &name : collection_names) {
227 if (visible_names_set.find(name) == visible_names_set.end()) {
235 std::string active_name;
236 active_name = node_extra_tags->
setData(
"active_collection", active_name);
256 bool apply_modifiers,
259 const Mesh *tmpmesh =
nullptr;
260 if (apply_modifiers) {
262 switch (export_mesh_type) {
268 dm = mesh_create_derived_render(
depsgraph, scene, ob, &
mask);
317 for (node = export_set; node; node = node->
next) {
320 if (ob->
type == obtype && ob->
data) {
333 for (node = export_set; node->
next && !sorted; node = node->
next) {
338 for (current = export_set; current->
next; current = current->
next) {
342 if (strcmp(a->
id.
name,
b->id.name) > 0) {
353 if (deform_bones_only) {
354 Bone *root =
nullptr;
362 return (aBone == root);
383 const std::string &pattern,
384 const std::string &replacement)
387 while ((
pos =
data.find(pattern,
pos)) != std::string::npos) {
388 data.replace(
pos, pattern.length(), replacement);
389 pos += replacement.length();
396 if (scale_to_scene) {
398 ob->
runtime->object_to_world.ptr(), bc_unit.
get_scale(), ob->object_to_world().ptr());
409 for (
Object *ob : *objects_done) {
410 if (ob->parent ==
nullptr) {
440 float mat_from[4][4];
454 bool use_beauty =
false;
455 bool tag_only =
false;
487 if (
STREQ(name, eBone->name)) {
501 int bit = 1u << layer;
515 std::string key = armature->
id.
name;
519 extended_bone_maps[key] =
result;
526 std::map<std::string, BoneExtensionMap *>::iterator map_it;
527 for (map_it = extended_bone_maps.begin(); map_it != extended_bone_maps.end(); ++map_it) {
529 for (
auto &extended_bone : *extended_bones) {
530 delete extended_bone.second;
532 extended_bones->clear();
533 delete extended_bones;
540 this->chain_length = 0;
541 this->is_leaf =
false;
542 this->tail[0] = 0.0f;
543 this->tail[1] = 0.5f;
544 this->tail[2] = 0.0f;
545 this->use_connect = -1;
548 this->has_custom_tail =
false;
549 this->has_custom_roll =
false;
569 chain_length = aLength;
585 this->has_custom_roll =
true;
590 return this->has_custom_roll;
600 this->tail[0] = vec[0];
601 this->tail[1] = vec[1];
602 this->tail[2] = vec[2];
603 this->has_custom_tail =
true;
608 return this->has_custom_tail;
618 if (s.empty() || (!isdigit(s[0]) && (s[0] !=
'-') && (s[0] !=
'+'))) {
623 strtol(s.c_str(), &p, 10);
630 this->bone_collections = bone_collections;
634 return this->bone_collections;
639 this->use_connect = use_connect;
644 return this->use_connect;
650 if (idgroup ==
nullptr) {
652 ebone->
prop = idgroup;
670 if (ebone->
prop ==
nullptr) {
690 switch (property->type) {
713 if (property && property->type ==
IDP_ARRAY && property->len == 16) {
715 for (
int i = 0;
i < 4;
i++) {
716 for (
int j = 0; j < 4; j++) {
747 if (adt ==
nullptr) {
756 SNPRINTF(prefix,
"pose.bones[\"%s\"]", bone_name_esc);
761 if (
STREQLEN(fcu->rna_path, prefix, strlen(prefix))) {
803 temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
810 temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
821 static float MIN_DISTANCE = 0.00001;
823 if (values.size() < 2) {
827 BCMatrixSampleMap::iterator it;
829 for (it = values.begin(); it != values.end(); ++it) {
830 const BCMatrix *matrix = it->second;
832 if (refmat ==
nullptr) {
837 if (!matrix->
in_range(*refmat, MIN_DISTANCE)) {
855 for (
int a = 0; a < ob->
totcol; a++) {
877 for (node = export_set; node; node = node->
next) {
939 float from_mat[4][4],
940 bool use_local_space)
945 static const float V0[3] = {0, 0, 0};
947 if (!
has_custom_props(bone, export_settings.get_keep_bind_info(),
"restpose_loc") &&
948 !
has_custom_props(bone, export_settings.get_keep_bind_info(),
"restpose_rot") &&
949 !
has_custom_props(bone, export_settings.get_keep_bind_info(),
"restpose_scale"))
959 if (export_settings.get_keep_bind_info()) {
962 if (use_local_space && bone->
parent) {
975 if (export_settings.get_keep_bind_info()) {
987 if (export_settings.get_keep_bind_info()) {
996 for (
int i = 0;
i < 3;
i++) {
997 double val = double(
v[
i]);
1005 for (
int i = 0;
i < 3;
i++) {
1012 for (
int i = 0;
i < 4;
i++) {
1013 for (
int j = 0; j < 4; j++) {
1021 for (
int i = 0;
i < 4;
i++) {
1022 for (
int j = 0; j < 4; j++) {
1030 for (
int i = 0;
i < 4;
i++) {
1031 for (
int j = 0; j < 4; j++) {
1039 for (
int i = 0;
i < 4;
i++) {
1040 for (
int j = 0; j < 4; j++) {
1048 for (
int i = 0;
i < 4;
i++) {
1049 for (
int j = 0; j < 4; j++) {
1065 return std::string(layer_name);
1087 if (num_layers && layer < num_layers) {
1091 return std::string(layer_name);
1101 nullptr, &ma->
id,
"Shader Nodetree",
"ShaderNodeTree");
1108 bContext *
C,
bNodeTree *ntree,
int node_type,
int locx,
int locy,
const std::string &label)
1112 if (label.length() > 0) {
1124 return bc_add_node(
C, ntree, node_type, locx, locy,
"");
1139 std::map<std::string, bNode *> nmap;
1156 bc_make_group(
C, ntree, nmap);
1167 Color default_color = {ma->
r, ma->
g, ma->
b, 1.0};
1178 Color default_color = {0, 0, 0, 1};
1184 double emission_strength = 0.0;
1186 if (emission_strength == 0.0) {
1193 COLLADASW::Color
col = cot.getColor();
1194 double final_color[3] = {
col.getRed(),
col.getGreen(),
col.getBlue()};
1198 double max_color = fmax(fmax(final_color[0], final_color[1]), final_color[2]);
1199 if (max_color > 1.0) {
1203 cot.getColor().set(final_color[0], final_color[1], final_color[2],
col.getAlpha());
1210 Color default_color = {0, 0, 0, 1.0};
1216 Color default_color = {0, 0, 0, 1.0};
1222 Color default_color = {0, 0, 0, 1.0};
1228 double alpha = ma->
a;
1258 double reflectivity = ma->
spec;
1263 return reflectivity;
1271 val = double(ref->
value);
1279 const Color &default_color,
1289 return bc_get_cot(default_color, with_alpha);
1296 for (
bNode *node : nodetree->all_nodes()) {
1305COLLADASW::ColorOrTexture
bc_get_cot(
float r,
float g,
float b,
float a)
1307 COLLADASW::Color color(r, g,
b, a);
1308 COLLADASW::ColorOrTexture cot(color);
1314 COLLADASW::Color color(
col[0],
col[1],
col[2], (with_alpha) ?
col[3] : 1.0);
1315 COLLADASW::ColorOrTexture cot(color);
Functions and classes to work with Actions.
Functions for backward compatibility with the legacy Action API.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
void ANIM_bonecoll_hide(bArmature *armature, BoneCollection *bcoll)
void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *name)
void ANIM_bonecoll_show(bArmature *armature, BoneCollection *bcoll)
BoneCollection * ANIM_armature_bonecoll_new(bArmature *armature, const char *name, int parent_index=-1)
std::map< int, const BCMatrix * > BCMatrixSampleMap
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
const bConstraintTypeInfo * BKE_constraint_typeinfo_get(struct bConstraint *con)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_active_layer_index(const CustomData *data, eCustomDataType type)
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, blender::StringRef name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop) ATTR_NONNULL()
Key * BKE_key_from_object(Object *ob)
LayerCollection * BKE_layer_collection_get_active(ViewLayer *view_layer)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void BKE_view_layer_base_select_and_set_active(ViewLayer *view_layer, Base *selbase)
General operations, lookup, etc. for materials.
Material * BKE_object_material_get(Object *ob, short act)
Mesh * BKE_mesh_copy_for_eval(const Mesh &source)
void BKE_mesh_tessface_ensure(Mesh *mesh)
void BKE_mesh_wrapper_ensure_mdata(Mesh *mesh)
#define SH_NODE_MIX_SHADER
#define SH_NODE_BSDF_PRINCIPLED
#define SH_NODE_ADD_SHADER
#define SH_NODE_BSDF_TRANSPARENT
#define SH_NODE_OUTPUT_MATERIAL
General operations, lookup, etc. for blender objects.
void BKE_object_apply_mat4(Object *ob, const float mat[4][4], bool use_compat, bool use_parent)
void * BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name) ATTR_NONNULL(1)
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BKE_scene_frame_set(Scene *scene, float frame)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
double double_round(double x, int ndigits)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void loc_eulO_size_to_mat4(float R[4][4], const float loc[3], const float eul[3], const float size[3], short order)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
bool invert_m4(float mat[4][4])
void mat4_to_size(float size[3], const float M[4][4])
void mat4_to_eul(float eul[3], const float mat[4][4])
void quat_to_mat4(float m[4][4], const float q[4])
void mul_qt_qtqt(float q[4], const float a[4], const float b[4])
void mat4_to_quat(float q[4], const float mat[4][4])
MINLINE void mul_v3db_db(double r[3], double f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define SNPRINTF(dst, format,...)
char * STRNCPY(char(&dst)[N], const char *src)
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STREQLEN(a, b, n)
void DEG_id_tag_update(ID *id, unsigned int flags)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ MOD_TRIANGULATE_QUAD_SHORTEDGE
Object is a sort of wrapper for general info.
void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
BMesh const char void * data
const BMAllocTemplate bm_mesh_allocsize_default
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const BMeshCreateParams *params)
BMesh Make Mesh.
void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams *params)
void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *mesh, const BMeshToMeshParams *params)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BM_mesh_triangulate(BMesh *bm, const int quad_method, const int ngon_method, const int min_vertices, const bool tag_only, BMOperator *op, BMOpSlot *slot_facemap_out, BMOpSlot *slot_facemap_double_out)
BPy_StructRNA * depsgraph
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void add_transform(Matrix &to, const Matrix &transform, const Matrix &from, bool inverted=false)
void get_matrix(DMatrix &matrix, bool transposed=false, int precision=-1) const
void apply_transform(Matrix &to, const Matrix &transform, const Matrix &from, bool inverse=false)
bool in_range(const BCMatrix &other, float distance) const
Depsgraph * get_depsgraph()
void set_use_connect(int use_connect)
void set_roll(float roll)
const std::vector< std::string > & get_bone_collections()
void set_bone_collections(std::vector< std::string > bone_collections)
void set_tail(const float vec[])
void set_leaf_bone(bool state)
BoneExtended(EditBone *aBone)
void set_chain_length(int aLength)
void set_name(const char *aName)
BoneExtensionMap & getExtensionMap(bArmature *armature)
float(& get_rotation())[4]
std::string translate_id(const char *idString)
Object * bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name)
COLLADASW::ColorOrTexture bc_get_specular(Material *ma)
COLLADASW::ColorOrTexture bc_get_ambient(Material *ma)
bool bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
IDProperty * bc_get_IDProperty(Bone *bone, const std::string &key)
void bc_copy_farray_m4(float *r, float a[4][4])
void bc_enable_fcurves(AnimData *adt, const char *bone_name)
bool bc_is_root_bone(Bone *aBone, bool deform_bones_only)
double bc_get_alpha(Material *ma)
void bc_add_global_transform(Matrix &to_mat, const Matrix &from_mat, const BCMatrix &global_transform, const bool invert)
bNode * bc_get_master_shader(Material *ma)
void bc_sanitize_v3(float v[3], int precision)
std::vector< bAction * > bc_getSceneActions(const bContext *C, Object *ob, bool all_actions)
COLLADASW::ColorOrTexture bc_get_cot(float r, float g, float b, float a)
std::string bc_url_encode(const std::string &data)
bool bc_has_animations(Object *ob)
void bc_apply_global_transform(Matrix &to_mat, const BCMatrix &global_transform, const bool invert)
COLLADASW::ColorOrTexture bc_get_emission(Material *ma)
COLLADASW::ColorOrTexture bc_get_reflective(Material *ma)
static bNode * bc_add_node(bContext *C, bNodeTree *ntree, int node_type, int locx, int locy, const std::string &label)
static std::string bc_get_uvlayer_name(Mesh *mesh, int layer)
bool isInteger(const std::string &s)
static bool has_custom_props(Bone *bone, bool enabled, const std::string &key)
void bc_rotate_from_reference_quat(float quat_to[4], float quat_from[4], float mat_to[4][4])
double bc_get_reflectivity(Material *ma)
static void bc_add_armature_collections(COLLADAFW::Node *node, ExtraTags *node_extra_tags, bArmature *arm)
COLLADASW::ColorOrTexture bc_get_cot_from_shader(bNode *shader, std::string nodeid, const Color &default_color, bool with_alpha)
void bc_copy_m4d_v44(double(&r)[4][4], std::vector< std::vector< double > > &a)
void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene)
Object * bc_get_assigned_armature(Object *ob)
float bc_get_property(Bone *bone, const std::string &key, float def)
void bc_add_default_shader(bContext *C, Material *ma)
Object * bc_add_armature(COLLADAFW::Node *node, ExtraTags *node_extra_tags, Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name)
static void bc_node_add_link(bNodeTree *ntree, bNode *from_node, int from_index, bNode *to_node, int to_index)
void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4])
std::string bc_get_action_id(const std::string &action_name, const std::string &ob_name, const std::string &channel_type, const std::string &axis_name, const std::string &axis_separator)
bool bc_is_animated(BCMatrixSampleMap &values)
void bc_triangulate_mesh(Mesh *mesh)
void bc_create_restpose_mat(BCExportSettings &export_settings, Bone *bone, float to_mat[4][4], float from_mat[4][4], bool use_local_space)
bool bc_get_float_from_shader(bNode *shader, double &val, std::string nodeid)
int bc_get_active_UVLayer(Object *ob)
static std::string bc_get_active_uvlayer_name(Mesh *mesh)
void bc_bubble_sort_by_Object_name(LinkNode *export_set)
EditBone * bc_get_edit_bone(bArmature *armature, const char *name)
bool bc_validateConstraints(bConstraint *con)
Mesh * bc_get_mesh_copy(BlenderContext &blender_context, Object *ob, BC_export_mesh_type export_mesh_type, bool apply_modifiers, bool triangulate)
double bc_get_shininess(Material *ma)
COLLADASW::ColorOrTexture bc_get_base_color(Material *ma)
static bNodeTree * prepare_material_nodetree(Material *ma)
double bc_get_ior(Material *ma)
void bc_get_property_vector(Bone *bone, const std::string &key, float val[3], const float def[3])
int bc_set_layer(int bitfield, int layer)
void bc_copy_v44_m4d(std::vector< std::vector< double > > &r, double(&a)[4][4])
void bc_update_scene(BlenderContext &blender_context, float ctime)
std::string bc_replace_string(std::string data, const std::string &pattern, const std::string &replacement)
bool bc_bone_matrix_local_get(Object *ob, Bone *bone, Matrix &mat, bool for_opensim)
float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, uint index)
void bc_copy_darray_m4d(double *r, double a[4][4])
void bc_decompose(float mat[4][4], float *loc, float eul[3], float quat[4], float *size)
void bc_copy_m4_farray(float r[4][4], float *a)
bool bc_get_property_matrix(Bone *bone, const std::string &key, float mat[4][4])
bool bc_has_object_type(LinkNode *export_set, short obtype)
bool bc_is_leaf_bone(Bone *bone)
int bc_test_parent_loop(Object *par, Object *ob)
const char * bc_CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
AnimData * bc_getSceneLightAnimData(Object *ob)
AnimData * bc_getSceneCameraAnimData(Object *ob)
const char * bc_CustomData_get_layer_name(const CustomData *data, eCustomDataType type, int n)
void bc_set_IDProperty(EditBone *ebone, const char *key, float value)
bAction * bc_getSceneObjectAction(Object *ob)
AnimData * bc_getSceneMaterialAnimData(Material *ma)
std::map< std::string, BoneExtended * > BoneExtensionMap
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
Vector< FCurve * > fcurves_for_assigned_action(AnimData *adt)
bool assigned_action_has_keyframes(AnimData *adt)
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRef prop_name, int32_t value, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_INT, set its name and value.
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRef prop_name, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_GROUP.
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, StringRefNull name, StringRefNull idname)
bNodeSocket * node_find_socket(bNode &node, eNodeSocketInOut in_out, StringRef identifier)
bNode * node_add_static_node(const bContext *C, bNodeTree &ntree, int type)
bNodeLink & node_add_link(bNodeTree &ntree, bNode &fromnode, bNodeSocket &fromsock, bNode &tonode, bNodeSocket &tosock)
bool parent_set(ReportList *reports, const bContext *C, Scene *scene, Object *const ob, Object *const par, int partype, bool xmirror, bool keep_transform, const int vert_par[3])
struct Collection * collection
struct bNodeTree * nodetree
ObjectRuntimeHandle * runtime
void(* evaluate_constraint)(struct bConstraint *con, struct bConstraintOb *cob, struct ListBase *targets)
struct bPoseChannel * parent