This commit is contained in:
Philip Rosedale 2013-10-10 10:14:35 -07:00
parent dd09d686fc
commit 72273d1469

View file

@ -19,28 +19,28 @@ const int FIELD_ELEMENTS = 1000;
/// Field is a lattice of vectors uniformly distributed in 3D with FIELD_ELEMENTS^(1/3) per side /// Field is a lattice of vectors uniformly distributed in 3D with FIELD_ELEMENTS^(1/3) per side
class Field { class Field {
public: public:
struct FieldElement { struct FieldElement {
glm::vec3 val; glm::vec3 val;
glm::vec3 center; glm::vec3 center;
glm::vec3 fld; glm::vec3 fld;
} _field[FIELD_ELEMENTS]; } _field[FIELD_ELEMENTS];
Field(float worldSize, float coupling); Field(float worldSize, float coupling);
/// The field value at a position in space, given simply as the value of the enclosing cell /// The field value at a position in space, given simply as the value of the enclosing cell
int value(float *ret, float *pos); int value(float *ret, float *pos);
/// Visualize the field as vector lines drawn at each center /// Visualize the field as vector lines drawn at each center
void render(); void render();
/// Add to the field value cell enclosing a location /// Add to the field value cell enclosing a location
void add(float* add, float *loc); void add(float* add, float *loc);
/// A particle with a position and velocity interacts with the field given the coupling /// A particle with a position and velocity interacts with the field given the coupling
/// constant passed when creating the field. /// constant passed when creating the field.
void interact(float deltaTime, const glm::vec3& pos, glm::vec3& vel); void interact(float deltaTime, const glm::vec3& pos, glm::vec3& vel);
/// Field evolves over timestep /// Field evolves over timestep
void simulate(float deltaTime); void simulate(float deltaTime);
private: private:
float _worldSize; float _worldSize;
float _coupling; float _coupling;
}; };
#endif #endif