Put forces into a folder. Added soft b3MouseForce

This commit is contained in:
Irlan
2019-06-29 14:51:35 -03:00
parent dddfba5b21
commit 0393933ecf
18 changed files with 485 additions and 82 deletions

View File

@ -68,9 +68,11 @@
#include <bounce/cloth/cloth.h>
#include <bounce/cloth/particle.h>
#include <bounce/cloth/cloth_triangle.h>
#include <bounce/cloth/strech_force.h>
#include <bounce/cloth/shear_force.h>
#include <bounce/cloth/spring_force.h>
#include <bounce/cloth/forces/strech_force.h>
#include <bounce/cloth/forces/shear_force.h>
#include <bounce/cloth/forces/spring_force.h>
#include <bounce/cloth/forces/mouse_force.h>
#include <bounce/cloth/garment/sewing_pattern.h>
#include <bounce/cloth/garment/garment.h>

View File

@ -163,6 +163,7 @@ private:
friend class b3ShearForce;
friend class b3StrechForce;
friend class b3SpringForce;
friend class b3MouseForce;
friend class b3ClothContactManager;
// Compute mass of each particle.

View File

@ -44,6 +44,7 @@ private:
friend class b3Particle;
friend class b3ShearForce;
friend class b3StrechForce;
friend class b3MouseForce;
friend class b3ClothContactManager;
friend class b3ParticleTriangleContact;
friend class b3ClothSolver;

View File

@ -32,6 +32,7 @@ enum b3ForceType
e_strechForce,
e_shearForce,
e_springForce,
e_mouseForce,
};
struct b3ForceDef

View File

@ -0,0 +1,140 @@
/*
* Copyright (c) 2016-2019 Irlan Robson https://irlanrobson.github.io
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef B3_MOUSE_FORCE_H
#define B3_MOUSE_FORCE_H
#include <bounce/cloth/forces/force.h>
class b3ClothTriangle;
struct b3MouseForceDef : public b3ForceDef
{
b3MouseForceDef()
{
type = e_mouseForce;
}
// Particle
b3Particle* particle;
// Triangle
b3ClothTriangle* triangle;
// Barycentric coordinates on triangle
float32 w2, w3, w4;
// Mouse stiffness
float32 mouse;
// Damping stiffness
float32 damping;
};
// Mouse force acting on a particle and triangle.
class b3MouseForce : public b3Force
{
public:
bool HasParticle(const b3Particle* particle) const;
b3Particle* GetParticle() const;
b3ClothTriangle* GetTriangle() const;
float32 GetMouseStiffness() const;
float32 GetDampingStiffness() const;
b3Vec3 GetActionForce1() const;
b3Vec3 GetActionForce2() const;
b3Vec3 GetActionForce3() const;
b3Vec3 GetActionForce4() const;
private:
friend class b3Force;
friend class b3Cloth;
b3MouseForce(const b3MouseForceDef* def);
~b3MouseForce();
void Apply(const b3ClothForceSolverData* data);
// Solver shared
// Particle
b3Particle* m_particle;
// Triangle
b3ClothTriangle* m_triangle;
// Barycentric coordinates
float32 m_w2, m_w3, m_w4;
// Mouse stiffness
float32 m_km;
// Damping stiffness
float32 m_kd;
// Action forces
b3Vec3 m_f1, m_f2, m_f3, m_f4;
};
inline b3Particle* b3MouseForce::GetParticle() const
{
return m_particle;
}
inline b3ClothTriangle* b3MouseForce::GetTriangle() const
{
return m_triangle;
}
inline float32 b3MouseForce::GetMouseStiffness() const
{
return m_km;
}
inline float32 b3MouseForce::GetDampingStiffness() const
{
return m_kd;
}
inline b3Vec3 b3MouseForce::GetActionForce1() const
{
return m_f1;
}
inline b3Vec3 b3MouseForce::GetActionForce2() const
{
return m_f2;
}
inline b3Vec3 b3MouseForce::GetActionForce3() const
{
return m_f3;
}
inline b3Vec3 b3MouseForce::GetActionForce4() const
{
return m_f4;
}
#endif

View File

@ -19,7 +19,7 @@
#ifndef B3_SHEAR_FORCE_H
#define B3_SHEAR_FORCE_H
#include <bounce/cloth/force.h>
#include <bounce/cloth/forces/force.h>
class b3ClothTriangle;

View File

@ -19,7 +19,7 @@
#ifndef B3_SPRING_FORCE_H
#define B3_SPRING_FORCE_H
#include <bounce/cloth/force.h>
#include <bounce/cloth/forces/force.h>
struct b3SpringForceDef : public b3ForceDef
{

View File

@ -19,7 +19,7 @@
#ifndef B3_STRECH_FORCE_H
#define B3_STRECH_FORCE_H
#include <bounce/cloth/force.h>
#include <bounce/cloth/forces/force.h>
class b3ClothTriangle;

View File

@ -123,6 +123,7 @@ private:
friend class b3StrechForce;
friend class b3ShearForce;
friend class b3SpringForce;
friend class b3MouseForce;
b3Particle(const b3ParticleDef& def, b3Cloth* cloth);
~b3Particle();