Skip to content

Commit

Permalink
make reaction volume a bit larger than the calculated collision volume
Browse files Browse the repository at this point in the history
  • Loading branch information
kateyy committed Feb 12, 2014
1 parent b0f8c4e commit 2eeebe4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions libelemate/particles/particlecollision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,13 @@ void ParticleCollision::treeCheck(const AxisAlignedBoundingBox & volume, const s
std::vector<vec3> leftReleasedPositions;
std::vector<vec3> rightReleasedPositions;

m_currentLeftHand->releaseParticlesGetPositions(volume, leftReleasedPositions);
m_currentRightHand->releaseParticlesGetPositions(volume, rightReleasedPositions);
float reactionBias = std::max(m_currentLeftHand->particleSize(), m_currentRightHand->particleSize());
AxisAlignedBoundingBox reactionVolume;
reactionVolume.extend(volume.llf() - vec3(reactionBias));
reactionVolume.extend(volume.urb() + vec3(reactionBias));

m_currentLeftHand->releaseParticlesGetPositions(reactionVolume, leftReleasedPositions);
m_currentRightHand->releaseParticlesGetPositions(reactionVolume, rightReleasedPositions);

glow::debug("deleting %; particles", leftReleasedPositions.size() + rightReleasedPositions.size());

Expand All @@ -200,6 +205,7 @@ void ParticleCollision::treeCheck(const AxisAlignedBoundingBox & volume, const s
newGroup->createParticles(rightReleasedPositions);

debug_intersectionBoxes.push_back(IntersectionBox(volume.llf(), volume.urb()));
debug_intersectionBoxes.push_back(IntersectionBox(reactionVolume.llf(), reactionVolume.urb()));

return;
}
Expand Down
5 changes: 5 additions & 0 deletions libelemate/particles/particlegroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const glowutils::AxisAlignedBoundingBox & ParticleGroup::boundingBox() const
return m_particleDrawable->boundingBox();
}

float ParticleGroup::particleSize() const
{
return m_particleSystem->getRestParticleDistance();
}

physx::PxParticleFluid * ParticleGroup::particleSystem()
{
return m_particleSystem;
Expand Down
5 changes: 3 additions & 2 deletions libelemate/particles/particlegroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ class ParticleGroup

const std::string & elementName() const;
const glowutils::AxisAlignedBoundingBox & boundingBox() const;
float particleSize() const;

physx::PxParticleFluid * particleSystem();

/** If specifing velocities, make sure that its size matches the positions size */
/** If specifying velocities, make sure that its size matches the positions size */
void createParticles(const std::vector<glm::vec3> & positions, const std::vector<glm::vec3> * velocities = nullptr);
/** Create a single particle at given position with given velocity. */
void createParticle(const glm::vec3 & position, const glm::vec3 & velocity);
Expand All @@ -71,7 +72,7 @@ class ParticleGroup
void emit(const float ratio, const glm::vec3 & position, const glm::vec3 & direction);
void stopEmit();

/** fill particles with all my particles which have there center in the specified boundingbox.
/** fill particles with all my particles which have there center in the specified bounding box.
* @param subbox is the axis aligned bounding box of the particles that are inside the input bounding box.
* This should only be called while the physics scene simulation is not running! */
void particlesInVolume(const glowutils::AxisAlignedBoundingBox & boundingBox, std::vector<glm::vec3> & particles, glowutils::AxisAlignedBoundingBox & subbox) const;
Expand Down

0 comments on commit 2eeebe4

Please sign in to comment.