Skip to content

Commit

Permalink
Remove the mouse pick sphere and replace with constant size points
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanmunawar committed Jan 25, 2024
1 parent dbe0b56 commit c8762be
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions ambf_framework/afFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5197,14 +5197,14 @@ afWorld::afWorld(): afIdentification(afType::WORLD), afModelManager(this){
m_enclosureW = 4.0;
m_enclosureH = 3.0;

m_pickSphere = new cMesh();
cCreateSphere(m_pickSphere, 0.02);
m_pickSphere->m_material->setPinkHot();
m_pickSphere->setUseDisplayList(true);
m_pickSphere->markForUpdate(false);
m_pickSphere->setLocalPos(0,0,0);
m_pickSphere->setShowEnabled(false);
addSceneObjectToWorld(m_pickSphere);
m_pickMultiPoint = new cMultiPoint();
m_pickMultiPoint->newPoint(cVector3d(0,0,0));
m_pickMultiPoint->setPointSize(15);
cColorf pickColor; pickColor.setGreenYellow();
m_pickMultiPoint->setPointColor(pickColor);
m_pickMultiPoint->setShowEnabled(false);
addSceneObjectToWorld(m_pickMultiPoint);

m_pickColor.setOrangeTomato();
m_pickColor.setTransparencyLevel(0.3);
m_namespace = "";
Expand Down Expand Up @@ -6021,8 +6021,8 @@ bool afWorld::pickBody(const cVector3d &rayFromWorld, const cVector3d &rayToWorl
{
cVector3d pickPos;
pickPos << rayCallback.m_hitPointWorld;
m_pickSphere->setLocalPos(pickPos);
m_pickSphere->setShowEnabled(true);
m_pickMultiPoint->setLocalPos(pickPos);
m_pickMultiPoint->setShowEnabled(true);
const btCollisionObject* colObject = rayCallback.m_collisionObject;
if (colObject->getInternalType() == btCollisionObject::CollisionObjectTypes::CO_RIGID_BODY){
btRigidBody* body = (btRigidBody*)btRigidBody::upcast(colObject);
Expand Down Expand Up @@ -6115,7 +6115,7 @@ bool afWorld::movePickedBody(const cVector3d &rayFromWorld, const cVector3d &ray

newLocation = rayFromWorld + dir;
// Set the position of grab sphere
m_pickSphere->setLocalPos(newLocation);
m_pickMultiPoint->setLocalPos(newLocation);

if (m_pickedConstraint){
btPoint2PointConstraint* pickCon = static_cast<btPoint2PointConstraint*>(m_pickedConstraint);
Expand Down Expand Up @@ -6145,7 +6145,7 @@ bool afWorld::movePickedBody(const cVector3d &rayFromWorld, const cVector3d &ray
dir *= m_oldPickingDist;

newPivotB = rayFromWorld + dir;
m_pickSphere->setLocalPos(newPivotB);
m_pickMultiPoint->setLocalPos(newPivotB);
m_pickedNodeGoal = newPivotB;
return true;
}
Expand All @@ -6170,7 +6170,7 @@ void afWorld::removePickingConstraint(){
}

if (m_pickedBulletRigidBody){
m_pickSphere->setShowEnabled(false);
m_pickMultiPoint->setShowEnabled(false);
m_pickedBulletRigidBody = nullptr;
}

Expand All @@ -6179,7 +6179,7 @@ void afWorld::removePickingConstraint(){
}

if (m_pickedSoftBody){
m_pickSphere->setShowEnabled(false);
m_pickMultiPoint->setShowEnabled(false);
m_pickedSoftBody = nullptr;
m_pickedNodeIdx = -1;
m_pickedNodeMass = 0;
Expand Down
2 changes: 1 addition & 1 deletion ambf_framework/afFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ class afWorld: public afIdentification, public afComm, public afModelManager{

cVector3d m_pickedOffset;

cMesh* m_pickSphere = nullptr;
cMultiPoint* m_pickMultiPoint = nullptr;

cPrecisionClock m_wallClock;

Expand Down

0 comments on commit c8762be

Please sign in to comment.