Skip to content

Commit 8b67bef

Browse files
committed
minor tweak (remove shared ptr typedef for solver)
1 parent a66e6a9 commit 8b67bef

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/CinderFlex.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace cinder
3636
solverDesc.maxParticles = particleCount;
3737
solverDesc.maxDiffuseParticles = 0;
3838

39-
mSolver = std::shared_ptr<NvFlexSolver>( NvFlexCreateSolver( mLibrary, &solverDesc ) );
39+
mSolver = NvFlexCreateSolver( mLibrary, &solverDesc );
4040

4141
// setup some decent default params
4242
float particleSize = 0.1f;
@@ -87,7 +87,7 @@ namespace cinder
8787
void CinderFlex::update( float elapsed )
8888
{
8989
// tick solver
90-
NvFlexUpdateSolver( mSolver.get(), elapsed, 1, NULL ); // &mTimers);
90+
NvFlexUpdateSolver( mSolver, elapsed, 1, NULL ); // &mTimers);
9191
}
9292

9393
void CinderFlex::setParticles( NvFlexBuffer* positions, NvFlexBuffer* velocities, NvFlexBuffer* phases, unsigned int particleCount, bool fluid )
@@ -107,21 +107,21 @@ namespace cinder
107107

108108
NvFlexUnmap( activeBuffer );
109109

110-
NvFlexSetActive( mSolver.get(), activeBuffer, NULL );
111-
NvFlexSetActiveCount( mSolver.get(), particleCount );
110+
NvFlexSetActive( mSolver, activeBuffer, NULL );
111+
NvFlexSetActiveCount( mSolver, particleCount );
112112

113113
// write to device (async)
114-
NvFlexSetParticles( mSolver.get(), positions, NULL );
115-
NvFlexSetVelocities( mSolver.get(), velocities, NULL );
116-
NvFlexSetPhases( mSolver.get(), phases, NULL );
114+
NvFlexSetParticles( mSolver, positions, NULL );
115+
NvFlexSetVelocities( mSolver, velocities, NULL );
116+
NvFlexSetPhases( mSolver, phases, NULL );
117117
}
118118

119119
void CinderFlex::getParticles( NvFlexBuffer* positions, NvFlexBuffer* velocities, NvFlexBuffer* phases, unsigned int particleCount )
120120
{
121121
// kick off async memory reads from device
122-
NvFlexGetParticles( mSolver.get(), positions, NULL );
123-
NvFlexGetVelocities( mSolver.get(), velocities, NULL );
124-
NvFlexGetPhases( mSolver.get(), phases, NULL );
122+
NvFlexGetParticles( mSolver, positions, NULL );
123+
NvFlexGetVelocities( mSolver, velocities, NULL );
124+
NvFlexGetPhases( mSolver, phases, NULL );
125125
}
126126

127127
}

src/CinderFlex.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#include "cinder/app/App.h"
1212
#include <NvFlex.h>
1313

14-
typedef std::shared_ptr<NvFlexLibrary> NvFlexLibraryRef;
15-
typedef std::shared_ptr<NvFlexSolver> NvFlexSolverRef;
16-
1714
namespace cinder
1815
{
1916
namespace flex
@@ -22,7 +19,7 @@ namespace cinder
2219
class CinderFlex
2320
{
2421
NvFlexLibrary* mLibrary;
25-
NvFlexSolverRef mSolver;
22+
NvFlexSolver* mSolver;
2623
NvFlexTimers mTimers;
2724
NvFlexParams mParams;
2825

@@ -42,7 +39,7 @@ namespace cinder
4239
const NvFlexParams& getParams() const { return mParams; }
4340

4441
// set the flex params (for some reason this has strange results if you call it multiple times per solver instance)
45-
void setParams( NvFlexParams& params ) { mParams = params; NvFlexSetParams( mSolver.get(), &mParams ); }
42+
void setParams( NvFlexParams& params ) { mParams = params; NvFlexSetParams( mSolver, &mParams ); }
4643

4744
// set the particles positions and velocities (memory should be flexAlloced)
4845
void setParticles( NvFlexBuffer* positions, NvFlexBuffer* velocities, NvFlexBuffer* phases, unsigned int particleCount, bool fluid );

0 commit comments

Comments
 (0)