Skip to content

Commit

Permalink
Restored parallelism of the space queries in chipmunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlo Pinciroli committed Oct 17, 2014
1 parent b5e3c22 commit 2a1a77c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpLayers layers, c
func,
};

cpSpaceLock(space); {
cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data);
cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data);
} cpSpaceUnlock(space, cpTrue);
/* cpSpaceLock(space); */
/* { */
cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data);
cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data);
/* } */
/* cpSpaceUnlock(space, cpTrue); */
}

typedef struct segQueryFirstContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ namespace argos {
}
}
}
/* Initialize mutex */
int nErrors = pthread_mutex_init(&m_tSpaceQueryMutex, NULL);
if(nErrors != 0) {
THROW_ARGOSEXCEPTION("Error creating thread mutexes " << ::strerror(nErrors));
}
}
catch(CARGoSException& ex) {
THROW_ARGOSEXCEPTION_NESTED("Error initializing the dynamics 2D engine \"" << GetId() << "\"", ex);
Expand Down Expand Up @@ -294,7 +289,6 @@ namespace argos {
const CRay3& c_ray) const {
/* Query all hits along the ray */
SDynamics2DSegmentHitData sHitData(c_ray);
pthread_mutex_lock(&m_tSpaceQueryMutex);
cpSpaceSegmentQuery(
m_ptSpace,
cpv(c_ray.GetStart().GetX(), c_ray.GetStart().GetY()),
Expand All @@ -303,7 +297,6 @@ namespace argos {
CP_NO_GROUP,
Dynamics2DSegmentQueryFunc,
&sHitData);
pthread_mutex_unlock(&m_tSpaceQueryMutex);
/* Check whether we have a hit */
if(sHitData.Body != NULL) {
f_t_on_ray = sHitData.T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace argos {
#include <argos3/core/simulator/entity/controllable_entity.h>
#include <argos3/core/simulator/physics_engine/physics_engine.h>
#include <argos3/plugins/simulator/physics_engines/dynamics2d/chipmunk-physics/include/chipmunk.h>
#include <pthread.h>

namespace argos {

Expand Down Expand Up @@ -167,7 +166,6 @@ namespace argos {
cpSpace* m_ptSpace;
cpBody* m_ptGroundBody;
Real m_fElevation;
mutable pthread_mutex_t m_tSpaceQueryMutex;

std::vector<CVector2> m_vecVertices;
std::vector<SBoundarySegment> m_vecSegments;
Expand Down

0 comments on commit 2a1a77c

Please sign in to comment.