16#include "COLLADABUPlatform.h"
41 const std::string &
id = node->getName();
42 return id.empty() ? node->getOriginalId().c_str() :
id.c_str();
48 : weights(skin.weights),
49 joint_data(skin.joint_data),
50 unit_converter(skin.unit_converter),
52 controller_uid(skin.controller_uid),
55 copy_m4_m4(bind_shape_matrix, (
float(*)[4])skin.bind_shape_matrix);
66 dest.setData(src.getData(), src.getCount());
68 dest.yieldOwnerShip();
72 COLLADAFW::IntValuesArray &dest)
74 dest.setData((
int *)src.getData(), src.getCount());
75 dest.yieldOwnerShip();
79 COLLADAFW::UIntValuesArray &dest)
81 dest.setData((
uint *)src.getData(), src.getCount());
82 dest.yieldOwnerShip();
87 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getJointsPerVertex(), joints_per_vertex);
88 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getWeightIndices(), weight_indices);
93 const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
94 for (
uint i = 0; i < weight.getValuesCount(); i++) {
103 joints_per_vertex.releaseMemory();
104 weight_indices.releaseMemory();
105 joint_indices.releaseMemory();
113 joint_data.push_back(jd);
118 controller_uid = co->getUniqueId();
121 const COLLADAFW::UniqueIdArray &joint_uids = co->getJoints();
122 for (
uint i = 0; i < joint_uids.getCount(); i++) {
123 joint_data[i].joint_uid = joint_uids[i];
146 this->ob_arm = ob_arm;
152 const COLLADAFW::UniqueId &uid = node->getUniqueId();
153 std::vector<JointData>::iterator it;
154 for (it = joint_data.begin(); it != joint_data.end(); it++) {
155 if ((*it).joint_uid == uid) {
171 return controller_uid;
176 const COLLADAFW::UniqueId &uid = node->getUniqueId();
177 std::vector<JointData>::iterator it;
178 for (it = joint_data.begin(); it != joint_data.end(); it++) {
179 if ((*it).joint_uid == uid) {
184 COLLADAFW::NodePointerArray &children = node->getChildNodes();
185 for (
uint i = 0; i < children.getCount(); i++) {
196 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
228 std::vector<JointData>::iterator it;
230 for (it = joint_data.begin(), joint_index = 0; it != joint_data.end(); it++, joint_index++) {
231 const char *name =
"Group";
234 if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) {
240 if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
258 for (
uint vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
260 uint limit = weight + joints_per_vertex[vertex];
261 for (; weight < limit; weight++) {
262 int joint = joint_indices[weight], joint_weight = weight_indices[weight];
292 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
293 std::vector<COLLADAFW::Node *> &result)
295 std::vector<COLLADAFW::Node *>::const_iterator it;
297 for (it = root_joints.begin(); it != root_joints.end(); it++) {
298 COLLADAFW::Node *root = *it;
299 std::vector<JointData>::iterator ji;
301 for (ji = joint_data.begin(); ji != joint_data.end(); ji++) {
302 if (joint_by_uid.find((*ji).joint_uid) != joint_by_uid.end()) {
304 COLLADAFW::Node *joint = joint_by_uid[(*ji).joint_uid];
308 if (std::find(result.begin(), result.end(), root) == result.end()) {
309 result.push_back(root);
319 if (node == tree_root) {
323 COLLADAFW::NodePointerArray &children = tree_root->getChildNodes();
324 for (
uint i = 0; i < children.getCount(); i++) {
static const char * bc_get_joint_name(T *node)
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
General operations, lookup, etc. for blender objects.
blender::float4x4 BKE_object_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *ob)
void BKE_object_apply_mat4(Object *ob, const float mat[4][4], bool use_compat, bool use_parent)
bool BKE_object_is_child_recursive(const Object *ob_parent, const Object *ob_child)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void DEG_id_tag_update(ID *id, unsigned int flags)
static const char * bc_get_joint_name(T *node)
void find_root_joints(const std::vector< COLLADAFW::Node * > &root_joints, std::map< COLLADAFW::UniqueId, COLLADAFW::Node * > &joint_by_uid, std::vector< COLLADAFW::Node * > &result)
const COLLADAFW::UniqueId & get_controller_uid()
void transfer_int_array_data_const(const COLLADAFW::IntValuesArray &src, COLLADAFW::IntValuesArray &dest)
void set_controller(const COLLADAFW::SkinController *co)
void link_armature(bContext *C, Object *ob, std::map< COLLADAFW::UniqueId, COLLADAFW::Node * > &joint_by_uid, TransformReader *tm)
Object * set_armature(Object *ob_arm)
void borrow_skin_controller_data(const COLLADAFW::SkinControllerData *skin)
bool uses_joint_or_descendant(COLLADAFW::Node *node)
Object * BKE_armature_from_object()
bool get_joint_inv_bind_matrix(float inv_bind_mat[4][4], COLLADAFW::Node *node)
void add_joint(const COLLADABU::Math::Matrix4 &matrix)
void transfer_uint_array_data_const(const COLLADAFW::UIntValuesArray &src, COLLADAFW::UIntValuesArray &dest)
void set_parent(Object *_parent)
bool find_node_in_tree(COLLADAFW::Node *node, COLLADAFW::Node *tree_root)
void transfer_array_data(T &src, T &dest)
bPoseChannel * get_pose_channel_from_node(COLLADAFW::Node *node)
Object * create_armature(Main *bmain, Scene *scene, ViewLayer *view_layer)
static void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4 &in)
Object * bc_add_object(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name)
bool bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, uint index)
const Depsgraph * depsgraph
ModifierData * modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
void vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, int assignmode)
ObjectRuntimeHandle * runtime