Titan
v1.0
A high-performance CUDA-based physics simulation sandbox for robotics, physics, and reinforcement learning.
|
Go to the documentation of this file.
16 #include <GLFW/glfw3.h>
19 #include <glm/glm.hpp>
20 #include <glm/gtc/matrix_transform.hpp>
24 #include <thrust/device_vector.h>
34 #define CUDA_CALLABLE_MEMBER __host__ __device__
36 #define CUDA_CALLABLE_MEMBER
40 #define CUDA_DEVICE __device__
51 virtual void generateBuffers() = 0;
52 virtual void draw() = 0;
72 glDeleteBuffers(1, &vertices);
73 glDeleteBuffers(1, &colors);
76 void generateBuffers();
79 void subdivide(GLfloat * arr, GLfloat *v1, GLfloat *v2, GLfloat *v3,
int depth);
80 void writeTriangle(GLfloat * arr, GLfloat *v1, GLfloat *v2, GLfloat *v3);
81 void normalize(GLfloat * v);
110 _initialized =
false;
122 glDeleteBuffers(1, &vertices);
123 glDeleteBuffers(1, &colors);
126 void generateBuffers();
181 struct LOCAL_CONSTRAINTS {
184 thrust::device_vector<CudaContactPlane> contact_plane;
185 thrust::device_vector<CudaConstraintPlane> constraint_plane;
186 thrust::device_vector<CudaBall> ball;
187 thrust::device_vector<CudaDirection> direction;
194 int num_contact_planes;
196 int num_constraint_planes;
199 double drag_coefficient;
203 struct CUDA_LOCAL_CONSTRAINTS {
204 CUDA_LOCAL_CONSTRAINTS() =
default;
206 CUDA_LOCAL_CONSTRAINTS(LOCAL_CONSTRAINTS & c);
208 CudaContactPlane * contact_plane;
209 CudaConstraintPlane * constraint_plane;
211 CudaDirection * direction;
213 int drag_coefficient;
216 int num_contact_planes;
218 int num_constraint_planes;
225 enum CONSTRAINT_TYPE {
226 CONSTRAINT_PLANE, CONTACT_PLANE, BALL, DIRECTION
242 void addConstraint(CONSTRAINT_TYPE type,
const Vec & v,
double d);
243 void clearConstraints();
261 Cube(
const Vec & center,
double side_length = 1.0);
308 #endif //TITAN_OBJECT_H
CudaBall * d_balls
Definition: object.h:173
Vec _center
Definition: object.h:68
int nx
Definition: object.h:283
Ball(const Vec ¢er, double radius)
Definition: object.h:57
CUDA_CALLABLE_MEMBER double norm() const
Definition: vec.h:149
CUDA_CALLABLE_MEMBER CudaBall(const Ball &b)
virtual ~Container()
Definition: object.h:232
int num_planes
Definition: object.h:175
#define CUDA_CALLABLE_MEMBER
Definition: object.h:36
Vec _center
Definition: object.h:284
~Cube()
Definition: object.h:259
void rotate(const Vec &axis, double angle)
void translate(const Vec &displ)
void setRestLengths(double len)
~Beam()
Definition: object.h:279
Vec _dims
Definition: object.h:274
int nz
Definition: object.h:283
double _friction
Definition: object.h:168
CudaContactPlane * d_planes
Definition: object.h:172
int nz
Definition: object.h:273
CUDA_CALLABLE_MEMBER void applyForce(CUDA_MASS *m)
double _side_length
Definition: object.h:263
std::vector< Mass * > masses
Definition: object.h:253
Lattice(const Vec ¢er, const Vec &dims, int nx=10, int ny=10, int nz=10)
CUDA_CALLABLE_MEMBER CudaBall(const Vec ¢er, double radius)
virtual ~Constraint()=default
Vec _center
Definition: object.h:98
CudaConstraintPlane()=default
Vec _dims
Definition: object.h:284
int ny
Definition: object.h:283
double _radius
Definition: object.h:97
Vec _normal
Definition: object.h:156
int num_balls
Definition: object.h:176
CUDA_CALLABLE_MEMBER void applyForce(CUDA_MASS *m)
double _radius
Definition: object.h:67
int ny
Definition: object.h:273
Vec _center
Definition: object.h:274
Cube(const Vec ¢er, double side_length=1.0)
Vec _tangent
Definition: object.h:167
Beam(const Vec ¢er, const Vec &dims, int nx=10, int ny=10, int nz=10)
void setMassValues(double m)
std::vector< Spring * > springs
Definition: object.h:254
double _friction
Definition: object.h:157
~Lattice()
Definition: object.h:269
CUDA_CALLABLE_MEMBER CudaConstraintPlane(const Vec &normal, double friction)
CUDA_CALLABLE_MEMBER CudaDirection(const Vec &tangent, double friction)
Vec _center
Definition: object.h:264
CUDA_CALLABLE_MEMBER void applyForce(CUDA_MASS *m)
int nx
Definition: object.h:273
void setSpringConstants(double k)