33 const std::string &
id = node->getName();
34 return id.empty() ? node->getOriginalId().c_str() :
id.c_str();
40 : weights(skin.weights),
41 joint_data(skin.joint_data),
42 unit_converter(skin.unit_converter),
44 controller_uid(skin.controller_uid),
47 copy_m4_m4(bind_shape_matrix, (
float(*)[4])skin.bind_shape_matrix);
58 dest.setData(src.getData(), src.getCount());
60 dest.yieldOwnerShip();
64 COLLADAFW::IntValuesArray &dest)
66 dest.setData((
int *)src.getData(), src.getCount());
67 dest.yieldOwnerShip();
71 COLLADAFW::UIntValuesArray &dest)
73 dest.setData((
uint *)src.getData(), src.getCount());
74 dest.yieldOwnerShip();
79 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getJointsPerVertex(), joints_per_vertex);
80 transfer_array_data((COLLADAFW::UIntValuesArray &)skin->getWeightIndices(), weight_indices);
85 const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
86 for (
uint i = 0;
i < weight.getValuesCount();
i++) {
95 joints_per_vertex.releaseMemory();
96 weight_indices.releaseMemory();
97 joint_indices.releaseMemory();
105 joint_data.push_back(jd);
110 controller_uid = co->getUniqueId();
113 const COLLADAFW::UniqueIdArray &joint_uids = co->getJoints();
114 for (
uint i = 0;
i < joint_uids.getCount();
i++) {
115 joint_data[
i].joint_uid = joint_uids[
i];
138 this->ob_arm = ob_arm;
144 const COLLADAFW::UniqueId &uid = node->getUniqueId();
145 std::vector<JointData>::iterator it;
146 for (it = joint_data.begin(); it != joint_data.end(); it++) {
147 if ((*it).joint_uid == uid) {
163 return controller_uid;
168 const COLLADAFW::UniqueId &uid = node->getUniqueId();
169 std::vector<JointData>::iterator it;
170 for (it = joint_data.begin(); it != joint_data.end(); it++) {
171 if ((*it).joint_uid == uid) {
176 COLLADAFW::NodePointerArray &children = node->getChildNodes();
177 for (
uint i = 0;
i < children.getCount();
i++) {
188 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
220 std::vector<JointData>::iterator it;
222 for (it = joint_data.begin(), joint_index = 0; it != joint_data.end(); it++, joint_index++) {
223 const char *name =
"Group";
226 if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) {
232 if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
250 for (
uint vertex = 0, weight = 0; vertex < joints_per_vertex.getCount(); vertex++) {
252 uint limit = weight + joints_per_vertex[vertex];
253 for (; weight < limit; weight++) {
254 int joint = joint_indices[weight], joint_weight = weight_indices[weight];
284 std::map<COLLADAFW::UniqueId, COLLADAFW::Node *> &joint_by_uid,
285 std::vector<COLLADAFW::Node *> &
result)
287 std::vector<COLLADAFW::Node *>::const_iterator it;
289 for (it = root_joints.begin(); it != root_joints.end(); it++) {
290 COLLADAFW::Node *root = *it;
291 std::vector<JointData>::iterator ji;
293 for (ji = joint_data.begin(); ji != joint_data.end(); ji++) {
294 if (joint_by_uid.find((*ji).joint_uid) != joint_by_uid.end()) {
296 COLLADAFW::Node *joint = joint_by_uid[(*ji).joint_uid];
311 if (node == tree_root) {
315 COLLADAFW::NodePointerArray &children = tree_root->getChildNodes();
316 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 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)
BPy_StructRNA * depsgraph
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)
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