Beispiel #1
0
// ----------------------------------------------------------------------------
ik_node_t* IKSolver::CreateIKNodeFromUrhoNode(const Node* node)
{
    ik_node_t* ikNode = ik_node_create(node->GetID());

    // Set initial position/rotation and pass in Node* as user data for later
    ikNode->original_position = Vec3Urho2IK(node->GetWorldPosition());
    ikNode->original_rotation = QuatUrho2IK(node->GetWorldRotation());
    ikNode->user_data = (void*)node;

    /*
     * If Urho's node has an effector, also create and attach one to the
     * library's node. At this point, the IKEffector component shouldn't be
     * holding a reference to any internal effector. Check this for debugging
     * purposes and log if it does.
     */
    IKEffector* effector = node->GetComponent<IKEffector>();
    if (effector != nullptr)
    {
#ifdef DEBUG
        if (effector->ikEffectorNode_ != NULL)
            URHO3D_LOGWARNINGF("[ik] IKEffector (attached to node \"%s\") has a reference to a possibly invalid internal effector. Should be NULL.", effector->GetNode()->GetName().CString());
#endif
        ik_effector_t* ikEffector = ik_effector_create();
        ik_node_attach_effector(ikNode, ikEffector); // ownership of effector

        effector->SetIKSolver(this);
        effector->SetIKEffectorNode(ikNode);
    }

    // Exact same deal with the constraint
    IKConstraint* constraint = node->GetComponent<IKConstraint>();
    if (constraint != nullptr)
    {
#ifdef DEBUG
        if (constraint->ikConstraintNode_ != NULL)
            URHO3D_LOGWARNINGF("[ik] IKConstraint (attached to node \"%s\") has a reference to a possibly invalid internal constraint. Should be NULL.", constraint->GetNode()->GetName().CString());
#endif

        constraint->SetIKConstraintNode(ikNode);
    }

    return ikNode;
}
Beispiel #2
0
StringHash StringHashRegister::RegisterString(const StringHash& hash, const char* string)
{
    if (mutex_)
        mutex_->Acquire();

    auto iter = map_.Find(hash);
    if (iter == map_.End())
    {
        map_.Populate(hash, string);
    }
    else if (iter->second_.Compare(string, false) != 0)
    {
        URHO3D_LOGWARNINGF("StringHash collision detected! Both \"%s\" and \"%s\" have hash #%s",
            string, iter->second_.CString(), hash.ToString().CString());
    }

    if (mutex_)
        mutex_->Release();

    return hash;
}