[Bf-blender-cvs] [6d3a1d8] hair_system: Fix for threading crash: Collision contact filtering has to happen outside the thread functions, or Bullet will have a race condition.
Lukas Tönne
noreply at git.blender.org
Fri Aug 8 12:11:04 CEST 2014
Commit: 6d3a1d871f30b1352a46bfe19eabb3aed1d91aa1
Author: Lukas Tönne
Date: Fri Aug 8 12:11:00 2014 +0200
Branches: hair_system
https://developer.blender.org/rB6d3a1d871f30b1352a46bfe19eabb3aed1d91aa1
Fix for threading crash: Collision contact filtering has to happen
outside the thread functions, or Bullet will have a race condition.
===================================================================
M source/blender/hair/intern/HAIR_solver.cpp
M source/blender/hair/intern/HAIR_solver.h
===================================================================
diff --git a/source/blender/hair/intern/HAIR_solver.cpp b/source/blender/hair/intern/HAIR_solver.cpp
index 6f6d588..81f1217 100644
--- a/source/blender/hair/intern/HAIR_solver.cpp
+++ b/source/blender/hair/intern/HAIR_solver.cpp
@@ -351,7 +351,7 @@ static void do_collision(const HairParams ¶ms, const SolverForces &forces, f
}
}
-void Solver::do_integration(float time, float timestep, const SolverTaskData &data) const
+void Solver::do_integration(float time, float timestep, const SolverTaskData &data, const PointContactCache &contacts) const
{
const int totsteps = m_params.substeps_forces; /* can have multiple integration steps per tick for accuracy */
float dt = timestep / (float)totsteps;
@@ -359,9 +359,6 @@ void Solver::do_integration(float time, float timestep, const SolverTaskData &da
int totcurve = data.totcurves;
/*int totpoint = data.totpoints;*/
- PointContactCache contacts;
- cache_point_contacts(contacts);
-
for (int step = 0; step < totsteps; ++step) {
/* clear forces */
@@ -456,13 +453,14 @@ void Solver::do_integration(float time, float timestep, const SolverTaskData &da
struct SolverPoolData {
const Solver *solver;
float time, timestep;
+ const PointContactCache *contacts;
};
static void step_threaded_func(TaskPool *pool, void *vtaskdata, int UNUSED(threadid))
{
const SolverPoolData *pooldata = (const SolverPoolData *)BLI_task_pool_userdata(pool);
SolverTaskData *taskdata = (SolverTaskData *)vtaskdata;
- pooldata->solver->do_integration(pooldata->time, pooldata->timestep, *taskdata);
+ pooldata->solver->do_integration(pooldata->time, pooldata->timestep, *taskdata, *pooldata->contacts);
}
static void advance_state(SolverData *data)
@@ -481,6 +479,10 @@ static void advance_state(SolverData *data)
void Solver::step_threaded(float time, float timestep, DebugThreadDataVector *debug_thread_data)
{
+ /* filter and cache Bullet contact information */
+ PointContactCache contacts;
+ cache_point_contacts(contacts);
+
typedef std::vector<SolverTaskData> SolverTaskVector;
const int max_points_per_task = 1024;
@@ -490,6 +492,7 @@ void Solver::step_threaded(float time, float timestep, DebugThreadDataVector *de
pooldata.solver = this;
pooldata.time = time;
pooldata.timestep = timestep;
+ pooldata.contacts = &contacts;
TaskScheduler *task_scheduler = BLI_task_scheduler_get();
TaskPool *task_pool = BLI_task_pool_create(task_scheduler, (void*)(&pooldata));
diff --git a/source/blender/hair/intern/HAIR_solver.h b/source/blender/hair/intern/HAIR_solver.h
index 24b7f41..b285ee7 100644
--- a/source/blender/hair/intern/HAIR_solver.h
+++ b/source/blender/hair/intern/HAIR_solver.h
@@ -167,7 +167,7 @@ public:
void cache_point_contacts(PointContactCache &cache) const;
- void do_integration(float time, float timestep, const SolverTaskData &data) const;
+ void do_integration(float time, float timestep, const SolverTaskData &data, const PointContactCache &contacts) const;
void step_threaded(float time, float timestep, DebugThreadDataVector *debug_thread_data = NULL);
More information about the Bf-blender-cvs
mailing list