Handling of perlin noise surfaces
This commit is contained in:
parent
588ff14b33
commit
0987290111
2 changed files with 14 additions and 1 deletions
11
spheroid.cpp
11
spheroid.cpp
|
@ -5,7 +5,7 @@
|
|||
#include "spheroid.hpp"
|
||||
|
||||
Spheroid::Spheroid(Point& _center, size_t _p, size_t _q) :
|
||||
ImplicitSurface(_center), init_p(_p), p(_p), q(_q), stiffness(0) {
|
||||
ImplicitSurface(_center), normal_vector(Point(0,0,1)), init_p(_p), p(_p), q(_q), stiffness(0) {
|
||||
_compute_volume();
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,15 @@ void Spheroid::check_vertical_plan_collision(double& abscissa) {
|
|||
}
|
||||
}
|
||||
|
||||
void Spheroid::check_perlin_collision(PerlinNoise perlin) {
|
||||
double height = perlin.noise(center.x, center.y);
|
||||
if ((center.z - p) <= height) {
|
||||
p = fmin(init_p, center.z- height );
|
||||
normal_vector = perlin.normal_vector(center.x, center.y);
|
||||
update_radius();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double Spheroid::operator() (double _x, double _y, double _z) const {
|
||||
return (pow(_x - center.x, 2) / pow(q, 2)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <cmath>
|
||||
#include "Implicit.hpp"
|
||||
#include "common_structures.hpp"
|
||||
#include "PerlinNoise.hpp"
|
||||
|
||||
const double PI = 3.141592653589793;
|
||||
|
||||
|
@ -19,6 +20,8 @@ class Spheroid : public ImplicitSurface {
|
|||
void set_stiffness(size_t _stiffness);
|
||||
void check_horizontal_plan_collision(double& height);
|
||||
void check_vertical_plan_collision(double& abscissa);
|
||||
void check_perlin_collision(PerlinNoise perlin);
|
||||
Point getNormalVector() const { return normal_vector;}
|
||||
double operator() (double _x, double _y, double _z) const;
|
||||
private:
|
||||
/**
|
||||
|
@ -27,6 +30,7 @@ class Spheroid : public ImplicitSurface {
|
|||
* V is the volume. Extremely useful to have a constant volume in the
|
||||
* ball
|
||||
**/
|
||||
Point normal_vector;
|
||||
double init_p, p, q;
|
||||
size_t stiffness;
|
||||
double V;
|
||||
|
|
Loading…
Reference in a new issue