Commit f92e2af9 authored by Jan Möbius's avatar Jan Möbius

Don't addroot joint twice

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12509 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 25a3f587
...@@ -17,7 +17,8 @@ SkeletonEditingPlugin::SkeletonEditingPlugin() ...@@ -17,7 +17,8 @@ SkeletonEditingPlugin::SkeletonEditingPlugin()
currentJoint_(-1), currentJoint_(-1),
jointPreview_(false), jointPreview_(false),
transformChildJoints_(false), transformChildJoints_(false),
transformAllFrames_(true) transformAllFrames_(true),
dblClick_(false)
{ {
manip_size_ = 1.0; manip_size_ = 1.0;
manip_size_modifier_ = 1.0; manip_size_modifier_ = 1.0;
...@@ -690,6 +691,8 @@ void SkeletonEditingPlugin::insertJoint(QMouseEvent* _event) ...@@ -690,6 +691,8 @@ void SkeletonEditingPlugin::insertJoint(QMouseEvent* _event)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
else if ( _event->type() == QEvent::MouseButtonDblClick ){ else if ( _event->type() == QEvent::MouseButtonDblClick ){
dblClick_ = true;
// end the path in the skeleton // end the path in the skeleton
if (currentSkeleton_ != -1){ if (currentSkeleton_ != -1){
cancelJointInsertion(); cancelJointInsertion();
...@@ -707,6 +710,7 @@ void SkeletonEditingPlugin::insertJoint(QMouseEvent* _event) ...@@ -707,6 +710,7 @@ void SkeletonEditingPlugin::insertJoint(QMouseEvent* _event)
lastHitPoint = PluginFunctions::viewerProperties().glState().unproject(viewCoords); lastHitPoint = PluginFunctions::viewerProperties().glState().unproject(viewCoords);
} }
int newSkeletonID = -1; int newSkeletonID = -1;
emit addEmptyObject(DATA_SKELETON, newSkeletonID); emit addEmptyObject(DATA_SKELETON, newSkeletonID);
...@@ -776,90 +780,95 @@ void SkeletonEditingPlugin::insertJoint(QMouseEvent* _event) ...@@ -776,90 +780,95 @@ void SkeletonEditingPlugin::insertJoint(QMouseEvent* _event)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// handle RELEASE events // handle RELEASE events
//---------------------------------------------------------------------- //----------------------------------------------------------------------
} else if ( _event->type() == QEvent::MouseButtonRelease ){ } else if ( _event->type() == QEvent::MouseButtonRelease){
if (!dblClick_) {
// CASE 1 : this is a release on a joint from which the insertion should be started // CASE 1 : this is a release on a joint from which the insertion should be started
if ( !jointPreview_ ){ if ( !jointPreview_ ){
// in // in
unsigned int node_idx, target_idx; unsigned int node_idx, target_idx;
ACG::Vec3d hitPoint; ACG::Vec3d hitPoint;
BaseObjectData* object; BaseObjectData* object;
//disable picking for anything but skeletons //disable picking for anything but skeletons
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
o_it->enablePicking( o_it->dataType(DATA_SKELETON) ); o_it->enablePicking( o_it->dataType(DATA_SKELETON) );
//perform picking //perform picking
bool successfullyPicked = PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_VERTEX, _event->pos(), node_idx, bool successfullyPicked = PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_VERTEX, _event->pos(), node_idx,
target_idx, &hitPoint) && PluginFunctions::getPickedObject(node_idx, object); target_idx, &hitPoint) && PluginFunctions::getPickedObject(node_idx, object);
//reenable picking for anything //reenable picking for anything
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it)
o_it->enablePicking( true ); o_it->enablePicking( true );
if ( successfullyPicked ){ if ( successfullyPicked ){
Skeleton* skeleton = PluginFunctions::skeleton( object ); Skeleton* skeleton = PluginFunctions::skeleton( object );
if ( !skeleton ) if ( !skeleton )
return; return;
currentSkeleton_ = object->id(); currentSkeleton_ = object->id();
Skeleton::Joint* joint = skeleton->joint( target_idx ); Skeleton::Joint* joint = skeleton->joint( target_idx );
if ( joint != 0 ){ if ( joint != 0 ){
if ( joint->selected() ){ if ( joint->selected() ){
//only if the joint is selected we are sure it was the same joint //only if the joint is selected we are sure it was the same joint
//like on the mouse press //like on the mouse press
Skeleton::Joint* tmpJoint = new Skeleton::Joint(joint); Skeleton::Joint* tmpJoint = new Skeleton::Joint(joint);
skeleton->addJoint(joint, tmpJoint); skeleton->addJoint(joint, tmpJoint);
currentJoint_ = tmpJoint->id(); currentJoint_ = tmpJoint->id();
jointPreview_ = true; jointPreview_ = true;
}
} }
} }
}
} else { } else {
// CASE 2 : a joint is already under construction // CASE 2 : a joint is already under construction
// so we insert the new joint at the current position // so we insert the new joint at the current position
BaseObjectData* baseObject = 0; BaseObjectData* baseObject = 0;
PluginFunctions::getObject(currentSkeleton_, baseObject); PluginFunctions::getObject(currentSkeleton_, baseObject);
if (baseObject == 0) if (baseObject == 0)
return; return;
Skeleton* skeleton = PluginFunctions::skeleton( baseObject ); Skeleton* skeleton = PluginFunctions::skeleton( baseObject );
if (skeleton == 0) if (skeleton == 0)
return; return;
Skeleton::Joint* joint = skeleton->joint( currentJoint_ ); Skeleton::Joint* joint = skeleton->joint( currentJoint_ );
if (joint != 0){ if (joint != 0){
ACG::Vec3d parentPosition = activePose(PluginFunctions::skeletonObject(baseObject))->globalTranslation(joint->parent()->id()); ACG::Vec3d parentPosition = activePose(PluginFunctions::skeletonObject(baseObject))->globalTranslation(joint->parent()->id());
ACG::Vec3d parentViewer = PluginFunctions::viewerProperties().glState().project(parentPosition); ACG::Vec3d parentViewer = PluginFunctions::viewerProperties().glState().project(parentPosition);
ACG::Vec3d viewCoords = ACG::Vec3d(_event->pos().x(), PluginFunctions::viewerProperties().glState().context_height() - _event->pos().y(), parentViewer[2]); ACG::Vec3d viewCoords = ACG::Vec3d(_event->pos().x(), PluginFunctions::viewerProperties().glState().context_height() - _event->pos().y(), parentViewer[2]);
ACG::Vec3d lastHitPoint = PluginFunctions::viewerProperties().glState().unproject(viewCoords); ACG::Vec3d lastHitPoint = PluginFunctions::viewerProperties().glState().unproject(viewCoords);
// set joint position // set joint position
setJointPosition(PluginFunctions::skeletonObject(baseObject), joint, lastHitPoint); setJointPosition(PluginFunctions::skeletonObject(baseObject), joint, lastHitPoint);
emit updatedObject(baseObject->id(), UPDATE_ALL); emit updatedObject(baseObject->id(), UPDATE_ALL);
Skeleton::Joint* tmpJoint = new Skeleton::Joint(joint); Skeleton::Joint* tmpJoint = new Skeleton::Joint(joint);
skeleton->addJoint(joint, tmpJoint); skeleton->addJoint(joint, tmpJoint);
setJointPosition(PluginFunctions::skeletonObject(baseObject), tmpJoint, lastHitPoint); setJointPosition(PluginFunctions::skeletonObject(baseObject), tmpJoint, lastHitPoint);
currentJoint_ = tmpJoint->id(); currentJoint_ = tmpJoint->id();
} }
} }
} else
dblClick_ = false;
} }
// keep the joint selection correct // keep the joint selection correct
if ( (_event->type() != QEvent::MouseButtonPress) ){ if ( (_event->type() != QEvent::MouseButtonPress) ){
BaseObjectData* baseObject = 0; BaseObjectData* baseObject = 0;
......
...@@ -206,6 +206,8 @@ class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, Key ...@@ -206,6 +206,8 @@ class SkeletonEditingPlugin : public QObject, BaseInterface, MouseInterface, Key
bool transformChildJoints_; bool transformChildJoints_;
bool transformAllFrames_; bool transformAllFrames_;
bool dblClick_;
private: private:
// object ids of all objects with active Manipulator // object ids of all objects with active Manipulator
std::vector< int > activeManipulators_; std::vector< int > activeManipulators_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment