CcdCollisionLoop.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2016, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_PHYSICS_CCDCOLLISIONLOOP_H
#define SURGSIM_PHYSICS_CCDCOLLISIONLOOP_H
#include "SurgSim/Physics/ComputationGroup.h"
namespace SurgSim
{
namespace Framework
{
class Logger;
}
namespace Collision
{
class CollisionPair;
struct Contact;
}
namespace Physics
{
class CcdCollision;
class ContactFiltering;
class UpdateCcdData;
class ContactConstraintGeneration;
class BuildMlcp;
class SolveMlcp;
class PushResults;
class PhysicsManager;
class CcdCollisionLoop : public Computation
{
public:
explicit CcdCollisionLoop(bool copyState);
~CcdCollisionLoop();
SURGSIM_CLASSNAME(SurgSim::Physics::CcdCollisionLoop);
std::shared_ptr<PhysicsManagerState> doUpdate(const double& dt,
const std::shared_ptr<PhysicsManagerState>& state) override;
friend class CcdCollisionLoopTest_FilterContacts_Test;
friend class CcdCollisionLoopTest_FilterContactsWithEpsilon_Test;
private:
std::unique_ptr<CcdCollision> m_ccdCollision;
std::unique_ptr<UpdateCcdData> m_updateCcdData;
std::unique_ptr<ContactFiltering> m_contactFilter;
std::unique_ptr<ContactConstraintGeneration> m_constraintGeneration;
std::unique_ptr<BuildMlcp> m_buildMlcp;
std::unique_ptr<SolveMlcp> m_solveMlcp;
std::unique_ptr<PushResults> m_pushResults;
size_t m_maxIterations;
double m_epsilonFactor;
bool findEarliestContact(const std::vector<std::shared_ptr<Collision::CollisionPair>>& ccdPairs,
double* currentTimeOfImpact);
void filterLaterContacts(std::vector<std::shared_ptr<Collision::CollisionPair>>* ccdPairs,
double epsilon,
double contactTime);
void backupContacts(std::vector<std::shared_ptr<Collision::CollisionPair>>* ccdPairs,
std::vector<std::list<std::shared_ptr<Collision::Contact>>>* oldContacts);
void restoreContacts(std::vector<std::shared_ptr<Collision::CollisionPair>>* ccdPairs,
std::vector<std::list<std::shared_ptr<Collision::Contact>>>* oldContacts);
void printContacts(const std::vector<std::shared_ptr<Collision::CollisionPair>>& ccdPairs);
std::shared_ptr<SurgSim::Framework::Logger> m_logger;
};
}
}
#endif
SurgSim::Physics::CcdCollisionLoop::m_maxIterations
size_t m_maxIterations
maximum number of iterations to run
Definition: CcdCollisionLoop.h:79
SurgSim::Physics::CcdCollisionLoop::m_constraintGeneration
std::unique_ptr< ContactConstraintGeneration > m_constraintGeneration
Definition: CcdCollisionLoop.h:73
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::CcdCollisionLoop::m_pushResults
std::unique_ptr< PushResults > m_pushResults
Definition: CcdCollisionLoop.h:76
SurgSim::Physics::CcdCollisionLoop
Definition: CcdCollisionLoop.h:46
SurgSim::Physics::CcdCollisionLoop::m_updateCcdData
std::unique_ptr< UpdateCcdData > m_updateCcdData
Definition: CcdCollisionLoop.h:71
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
SurgSim::Physics::CcdCollisionLoop::m_solveMlcp
std::unique_ptr< SolveMlcp > m_solveMlcp
Definition: CcdCollisionLoop.h:75
SurgSim::Physics::CcdCollisionLoop::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Definition: CcdCollisionLoop.h:118
SurgSim::Physics::CcdCollisionLoop::m_ccdCollision
std::unique_ptr< CcdCollision > m_ccdCollision
Definition: CcdCollisionLoop.h:70
SurgSim::Physics::Computation
Encapsulates a calculation over a selection of objects, needs to be subclassed to be used...
Definition: Computation.h:32
SurgSim::Physics::CcdCollisionLoop::m_contactFilter
std::unique_ptr< ContactFiltering > m_contactFilter
Definition: CcdCollisionLoop.h:72
SurgSim::Physics::CcdCollisionLoop::m_buildMlcp
std::unique_ptr< BuildMlcp > m_buildMlcp
Definition: CcdCollisionLoop.h:74
ComputationGroup.h
SurgSim::Physics::CcdCollisionLoop::m_epsilonFactor
double m_epsilonFactor
epsilon as a fraction of dt, i.e.
Definition: CcdCollisionLoop.h:84