Merge branch 'master' into vegetation
Conflicts: src/basics/Color.inline.cpp
This commit is contained in:
commit
230fd6644e
27 changed files with 222 additions and 235 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "Color.inline.cpp"
|
#include "Color.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cassert>
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
|
|
||||||
const Color paysages::basics::COLOR_TRANSPARENT = {0.0, 0.0, 0.0, 0.0};
|
const Color paysages::basics::COLOR_TRANSPARENT = {0.0, 0.0, 0.0, 0.0};
|
||||||
|
@ -11,6 +12,12 @@ const Color paysages::basics::COLOR_BLUE = {0.0, 0.0, 1.0, 1.0};
|
||||||
const Color paysages::basics::COLOR_WHITE = {1.0, 1.0, 1.0, 1.0};
|
const Color paysages::basics::COLOR_WHITE = {1.0, 1.0, 1.0, 1.0};
|
||||||
const Color paysages::basics::COLOR_GREY = {0.5, 0.5, 0.5, 1.0};
|
const Color paysages::basics::COLOR_GREY = {0.5, 0.5, 0.5, 1.0};
|
||||||
|
|
||||||
|
Color::Color(double r, double g, double b, double a) : r(r), g(g), b(b), a(a) {
|
||||||
|
}
|
||||||
|
|
||||||
|
Color::Color(const Color &col) : r(col.r), g(col.g), b(col.b), a(col.a) {
|
||||||
|
}
|
||||||
|
|
||||||
void Color::save(PackStream *stream) const {
|
void Color::save(PackStream *stream) const {
|
||||||
stream->write(&r);
|
stream->write(&r);
|
||||||
stream->write(&g);
|
stream->write(&g);
|
||||||
|
@ -24,3 +31,148 @@ void Color::load(PackStream *stream) {
|
||||||
stream->read(&b);
|
stream->read(&b);
|
||||||
stream->read(&a);
|
stream->read(&a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Color::to32BitRGBA() const {
|
||||||
|
return (((unsigned int)(a * 255.0)) << 24) | (((unsigned int)(b * 255.0)) << 16) |
|
||||||
|
(((unsigned int)(g * 255.0)) << 8) | ((unsigned int)(r * 255.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Color::to32BitBGRA() const {
|
||||||
|
return (((unsigned int)(a * 255.0)) << 24) | (((unsigned int)(r * 255.0)) << 16) |
|
||||||
|
(((unsigned int)(g * 255.0)) << 8) | ((unsigned int)(b * 255.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Color::to32BitARGB() const {
|
||||||
|
return (((unsigned int)(b * 255.0)) << 24) | (((unsigned int)(g * 255.0)) << 16) |
|
||||||
|
(((unsigned int)(r * 255.0)) << 8) | ((unsigned int)(a * 255.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Color::to32BitABGR() const {
|
||||||
|
return (((unsigned int)(r * 255.0)) << 24) | (((unsigned int)(g * 255.0)) << 16) |
|
||||||
|
(((unsigned int)(b * 255.0)) << 8) | ((unsigned int)(a * 255.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::from32BitRGBA(unsigned int col) {
|
||||||
|
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
|
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::from32BitBGRA(unsigned int col) {
|
||||||
|
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
|
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::from32BitARGB(unsigned int col) {
|
||||||
|
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
|
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::from32BitABGR(unsigned int col) {
|
||||||
|
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
||||||
|
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Color::mask(const Color &mask) {
|
||||||
|
double new_a;
|
||||||
|
new_a = a + mask.a - (a * mask.a);
|
||||||
|
r = (mask.r * mask.a + r * a - r * a * mask.a) / new_a;
|
||||||
|
g = (mask.g * mask.a + g * a - g * a * mask.a) / new_a;
|
||||||
|
b = (mask.b * mask.a + b * a - b * a * mask.a) / new_a;
|
||||||
|
a = new_a;
|
||||||
|
|
||||||
|
/*double mask_weight = mask->a;
|
||||||
|
double base_weight = 1.0 - mask_weight;
|
||||||
|
|
||||||
|
base->r = mask->r * mask_weight + base->r * base_weight;
|
||||||
|
base->g = mask->g * mask_weight + base->g * base_weight;
|
||||||
|
base->b = mask->b * mask_weight + base->b * base_weight;
|
||||||
|
base->a = base->a + mask_weight * (1.0 - base->a);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
double Color::normalize() {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
assert(r >= 0.0);
|
||||||
|
assert(g >= 0.0);
|
||||||
|
assert(b >= 0.0);
|
||||||
|
assert(a >= 0.0);
|
||||||
|
#ifdef isnan
|
||||||
|
assert(!isnan(r));
|
||||||
|
assert(!isnan(g));
|
||||||
|
assert(!isnan(b));
|
||||||
|
assert(!isnan(a));
|
||||||
|
#endif
|
||||||
|
#ifdef isfinite
|
||||||
|
assert(isfinite(r));
|
||||||
|
assert(isfinite(g));
|
||||||
|
assert(isfinite(b));
|
||||||
|
assert(isfinite(a));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (r > 1.0) {
|
||||||
|
r = 1.0;
|
||||||
|
}
|
||||||
|
if (g > 1.0) {
|
||||||
|
g = 1.0;
|
||||||
|
}
|
||||||
|
if (b > 1.0) {
|
||||||
|
b = 1.0;
|
||||||
|
}
|
||||||
|
return 1.0;
|
||||||
|
/*double max = colorGetValue(col);
|
||||||
|
|
||||||
|
assert(max >= 0.0);
|
||||||
|
|
||||||
|
if (max > 1.0)
|
||||||
|
{
|
||||||
|
col->r /= max;
|
||||||
|
col->g /= max;
|
||||||
|
col->b /= max;
|
||||||
|
}
|
||||||
|
return max;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::normalized() {
|
||||||
|
Color col = *this;
|
||||||
|
col.normalize();
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Color::getValue() const {
|
||||||
|
double max;
|
||||||
|
|
||||||
|
max = r;
|
||||||
|
if (g > max) {
|
||||||
|
max = g;
|
||||||
|
}
|
||||||
|
if (b > max) {
|
||||||
|
max = b;
|
||||||
|
}
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Color::getPower() const {
|
||||||
|
return r + g + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Color::limitPower(double max_power) {
|
||||||
|
double power = r + g + b;
|
||||||
|
|
||||||
|
if (power > max_power) {
|
||||||
|
double factor = max_power / power;
|
||||||
|
|
||||||
|
r *= factor;
|
||||||
|
g *= factor;
|
||||||
|
b *= factor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::add(const Color &other) const {
|
||||||
|
return Color(r + other.r, g + other.g, b + other.b, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color Color::lerp(const Color &other, double f) const {
|
||||||
|
Color result(r * (1.0 - f) + other.r * f, g * (1.0 - f) + other.g * f, b * (1.0 - f) + other.b * f,
|
||||||
|
a * (1.0 - f) + other.a * f);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -1,164 +0,0 @@
|
||||||
#define COLOR_INLINE_CPP
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
#include <cmath>
|
|
||||||
#include <cassert>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef COLOR_H
|
|
||||||
#define METHSPEC inline
|
|
||||||
#else
|
|
||||||
#include "Color.h"
|
|
||||||
#define METHSPEC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
METHSPEC Color::Color(double r, double g, double b, double a) : r(r), g(g), b(b), a(a) {
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color::Color(const Color &col) : r(col.r), g(col.g), b(col.b), a(col.a) {
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC unsigned int Color::to32BitRGBA() const {
|
|
||||||
return (((unsigned int)(a * 255.0)) << 24) | (((unsigned int)(b * 255.0)) << 16) |
|
|
||||||
(((unsigned int)(g * 255.0)) << 8) | ((unsigned int)(r * 255.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC unsigned int Color::to32BitBGRA() const {
|
|
||||||
return (((unsigned int)(a * 255.0)) << 24) | (((unsigned int)(r * 255.0)) << 16) |
|
|
||||||
(((unsigned int)(g * 255.0)) << 8) | ((unsigned int)(b * 255.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC unsigned int Color::to32BitARGB() const {
|
|
||||||
return (((unsigned int)(b * 255.0)) << 24) | (((unsigned int)(g * 255.0)) << 16) |
|
|
||||||
(((unsigned int)(r * 255.0)) << 8) | ((unsigned int)(a * 255.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC unsigned int Color::to32BitABGR() const {
|
|
||||||
return (((unsigned int)(r * 255.0)) << 24) | (((unsigned int)(g * 255.0)) << 16) |
|
|
||||||
(((unsigned int)(b * 255.0)) << 8) | ((unsigned int)(a * 255.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color Color::from32BitRGBA(unsigned int col) {
|
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color Color::from32BitBGRA(unsigned int col) {
|
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color Color::from32BitARGB(unsigned int col) {
|
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color Color::from32BitABGR(unsigned int col) {
|
|
||||||
return Color(((double)(col & 0x000000FF)) / 255.0, ((double)((col & 0x0000FF00) >> 8)) / 255.0,
|
|
||||||
((double)((col & 0x00FF0000) >> 16)) / 255.0, ((double)((col & 0xFF000000) >> 24)) / 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC void Color::mask(const Color &mask) {
|
|
||||||
double new_a;
|
|
||||||
new_a = a + mask.a - (a * mask.a);
|
|
||||||
r = (mask.r * mask.a + r * a - r * a * mask.a) / new_a;
|
|
||||||
g = (mask.g * mask.a + g * a - g * a * mask.a) / new_a;
|
|
||||||
b = (mask.b * mask.a + b * a - b * a * mask.a) / new_a;
|
|
||||||
a = new_a;
|
|
||||||
|
|
||||||
/*double mask_weight = mask->a;
|
|
||||||
double base_weight = 1.0 - mask_weight;
|
|
||||||
|
|
||||||
base->r = mask->r * mask_weight + base->r * base_weight;
|
|
||||||
base->g = mask->g * mask_weight + base->g * base_weight;
|
|
||||||
base->b = mask->b * mask_weight + base->b * base_weight;
|
|
||||||
base->a = base->a + mask_weight * (1.0 - base->a);*/
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC double Color::normalize() {
|
|
||||||
#ifndef NDEBUG
|
|
||||||
assert(r >= 0.0);
|
|
||||||
assert(g >= 0.0);
|
|
||||||
assert(b >= 0.0);
|
|
||||||
assert(a >= 0.0);
|
|
||||||
#ifdef isnan
|
|
||||||
assert(!isnan(r));
|
|
||||||
assert(!isnan(g));
|
|
||||||
assert(!isnan(b));
|
|
||||||
assert(!isnan(a));
|
|
||||||
#endif
|
|
||||||
#ifdef isfinite
|
|
||||||
assert(isfinite(r));
|
|
||||||
assert(isfinite(g));
|
|
||||||
assert(isfinite(b));
|
|
||||||
assert(isfinite(a));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (r > 1.0) {
|
|
||||||
r = 1.0;
|
|
||||||
}
|
|
||||||
if (g > 1.0) {
|
|
||||||
g = 1.0;
|
|
||||||
}
|
|
||||||
if (b > 1.0) {
|
|
||||||
b = 1.0;
|
|
||||||
}
|
|
||||||
return 1.0;
|
|
||||||
/*double max = colorGetValue(col);
|
|
||||||
|
|
||||||
assert(max >= 0.0);
|
|
||||||
|
|
||||||
if (max > 1.0)
|
|
||||||
{
|
|
||||||
col->r /= max;
|
|
||||||
col->g /= max;
|
|
||||||
col->b /= max;
|
|
||||||
}
|
|
||||||
return max;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color Color::normalized() {
|
|
||||||
Color col = *this;
|
|
||||||
col.normalize();
|
|
||||||
return col;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC double Color::getValue() const {
|
|
||||||
double max;
|
|
||||||
|
|
||||||
max = r;
|
|
||||||
if (g > max) {
|
|
||||||
max = g;
|
|
||||||
}
|
|
||||||
if (b > max) {
|
|
||||||
max = b;
|
|
||||||
}
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC double Color::getPower() const {
|
|
||||||
return r + g + b;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC void Color::limitPower(double max_power) {
|
|
||||||
double power = r + g + b;
|
|
||||||
|
|
||||||
if (power > max_power) {
|
|
||||||
double factor = max_power / power;
|
|
||||||
|
|
||||||
r *= factor;
|
|
||||||
g *= factor;
|
|
||||||
b *= factor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color Color::add(const Color &other) const {
|
|
||||||
return Color(r + other.r, g + other.g, b + other.b, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Color Color::lerp(const Color &other, double f) const {
|
|
||||||
Color result(r * (1.0 - f) + other.r * f, g * (1.0 - f) + other.g * f, b * (1.0 - f) + other.b * f,
|
|
||||||
a * (1.0 - f) + other.a * f);
|
|
||||||
return result;
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "InfiniteCylinder.h"
|
#include "InfiniteCylinder.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
|
|
||||||
#define EPS 1E-8
|
#define EPS 1E-8
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "InfinitePlane.h"
|
#include "InfinitePlane.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
#include "InfiniteRay.h"
|
#include "InfiniteRay.h"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
namespace paysages {
|
namespace paysages {
|
||||||
namespace basics {
|
namespace basics {
|
||||||
|
|
||||||
class NoiseFunctionPerlin {
|
class BASICSSHARED_EXPORT NoiseFunctionPerlin {
|
||||||
public:
|
public:
|
||||||
NoiseFunctionPerlin();
|
NoiseFunctionPerlin();
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
namespace paysages {
|
namespace paysages {
|
||||||
namespace basics {
|
namespace basics {
|
||||||
|
|
||||||
class NoiseFunctionSimplex : public FractalNoise {
|
class BASICSSHARED_EXPORT NoiseFunctionSimplex : public FractalNoise {
|
||||||
virtual double getBase2d(double x, double y) const override;
|
virtual double getBase2d(double x, double y) const override;
|
||||||
virtual double getBase3d(double x, double y, double z) const override;
|
virtual double getBase3d(double x, double y, double z) const override;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "SpaceSegment.h"
|
#include "SpaceSegment.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include "SpaceGridIterator.h"
|
#include "SpaceGridIterator.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Sphere.h"
|
#include "Sphere.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
#include "InfiniteRay.h"
|
#include "InfiniteRay.h"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "Vector3.inline.cpp"
|
#include "Vector3.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
|
@ -16,6 +16,10 @@ Vector3::Vector3(const VectorSpherical &v)
|
||||||
: x(v.r * cos(v.phi) * cos(v.theta)), y(v.r * sin(v.theta)), z(-v.r * sin(v.phi) * cos(v.theta)) {
|
: x(v.r * cos(v.phi) * cos(v.theta)), y(v.r * sin(v.theta)), z(-v.r * sin(v.phi) * cos(v.theta)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3::Vector3(double x, double y, double z) : x(x), y(y), z(z) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Vector3::save(PackStream *stream) const {
|
void Vector3::save(PackStream *stream) const {
|
||||||
stream->write(&x);
|
stream->write(&x);
|
||||||
stream->write(&y);
|
stream->write(&y);
|
||||||
|
@ -27,6 +31,48 @@ void Vector3::load(PackStream *stream) {
|
||||||
stream->read(&z);
|
stream->read(&z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::add(double x, double y, double z) const {
|
||||||
|
return Vector3(this->x + x, this->y + y, this->z + z);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::add(const Vector3 &other) const {
|
||||||
|
return Vector3(x + other.x, y + other.y, z + other.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::sub(const Vector3 &other) const {
|
||||||
|
return Vector3(x - other.x, y - other.y, z - other.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::inverse() const {
|
||||||
|
return Vector3(-x, -y, -z);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::scale(double scaling) const {
|
||||||
|
return Vector3(x * scaling, y * scaling, z * scaling);
|
||||||
|
}
|
||||||
|
|
||||||
|
double Vector3::getNorm() const {
|
||||||
|
return sqrt(x * x + y * y + z * z);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::normalize() const {
|
||||||
|
double norm = sqrt(x * x + y * y + z * z);
|
||||||
|
if (norm == 0.0) {
|
||||||
|
return VECTOR_ZERO;
|
||||||
|
} else {
|
||||||
|
norm = 1.0 / norm;
|
||||||
|
return Vector3(x * norm, y * norm, z * norm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double Vector3::dotProduct(const Vector3 &other) const {
|
||||||
|
return x * other.x + y * other.y + z * other.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::crossProduct(const Vector3 &other) const {
|
||||||
|
return Vector3(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
|
||||||
|
}
|
||||||
|
|
||||||
static inline double _euclidGet2DAngle(double x, double y) {
|
static inline double _euclidGet2DAngle(double x, double y) {
|
||||||
// TEMP Copy of old euclid.c
|
// TEMP Copy of old euclid.c
|
||||||
double nx, ny, d, ret;
|
double nx, ny, d, ret;
|
||||||
|
|
|
@ -90,11 +90,4 @@ BASICSSHARED_EXPORT extern const Vector3 VECTOR_WEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inlining
|
|
||||||
#if PAYSAGES_USE_INLINING
|
|
||||||
#ifndef VECTOR3_INLINE_CPP
|
|
||||||
#include "Vector3.inline.cpp"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // VECTOR3_H
|
#endif // VECTOR3_H
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
#define VECTOR3_INLINE_CPP
|
|
||||||
|
|
||||||
#ifdef VECTOR3_H
|
|
||||||
#define METHSPEC inline
|
|
||||||
#else
|
|
||||||
#include "Vector3.h"
|
|
||||||
#define METHSPEC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
METHSPEC Vector3::Vector3(double x, double y, double z) : x(x), y(y), z(z) {
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Vector3 Vector3::add(double x, double y, double z) const {
|
|
||||||
return Vector3(this->x + x, this->y + y, this->z + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Vector3 Vector3::add(const Vector3 &other) const {
|
|
||||||
return Vector3(x + other.x, y + other.y, z + other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Vector3 Vector3::sub(const Vector3 &other) const {
|
|
||||||
return Vector3(x - other.x, y - other.y, z - other.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Vector3 Vector3::inverse() const {
|
|
||||||
return Vector3(-x, -y, -z);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Vector3 Vector3::scale(double scaling) const {
|
|
||||||
return Vector3(x * scaling, y * scaling, z * scaling);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC double Vector3::getNorm() const {
|
|
||||||
return sqrt(x * x + y * y + z * z);
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Vector3 Vector3::normalize() const {
|
|
||||||
double norm = sqrt(x * x + y * y + z * z);
|
|
||||||
if (norm == 0.0) {
|
|
||||||
return VECTOR_ZERO;
|
|
||||||
} else {
|
|
||||||
norm = 1.0 / norm;
|
|
||||||
return Vector3(x * norm, y * norm, z * norm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC double Vector3::dotProduct(const Vector3 &other) const {
|
|
||||||
return x * other.x + y * other.y + z * other.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
METHSPEC Vector3 Vector3::crossProduct(const Vector3 &other) const {
|
|
||||||
return Vector3(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x);
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "AtmosphereDefinition.h"
|
#include "AtmosphereDefinition.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "PackStream.h"
|
#include "PackStream.h"
|
||||||
#include "RandomGenerator.h"
|
#include "RandomGenerator.h"
|
||||||
#include "FloatNode.h"
|
#include "FloatNode.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "VegetationPresenceDefinition.h"
|
#include "VegetationPresenceDefinition.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "TerrainDefinition.h"
|
#include "TerrainDefinition.h"
|
||||||
#include "VegetationLayerDefinition.h"
|
#include "VegetationLayerDefinition.h"
|
||||||
|
|
|
@ -9,7 +9,7 @@ vec3 noiseNormal2d(vec2 location, float detail)
|
||||||
vec3 normal = vec3(0.0, 0.0, 0.0);
|
vec3 normal = vec3(0.0, 0.0, 0.0);
|
||||||
for (float scaling = 1.0; scaling < 400.0; scaling *= 1.5)
|
for (float scaling = 1.0; scaling < 400.0; scaling *= 1.5)
|
||||||
{
|
{
|
||||||
normal += texture2D(simplexSampler, location * 0.01 * scaling).xyz;
|
normal += texture(simplexSampler, location * 0.01 * scaling).xyz;
|
||||||
}
|
}
|
||||||
return normalize(normal);
|
return normalize(normal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "CloudBasicLayerRenderer.h"
|
#include "CloudBasicLayerRenderer.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
#include "CloudLayerDefinition.h"
|
#include "CloudLayerDefinition.h"
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "NoiseGenerator.h"
|
#include "NoiseGenerator.h"
|
||||||
|
@ -12,8 +14,6 @@
|
||||||
#include "Logs.h"
|
#include "Logs.h"
|
||||||
#include "FloatNode.h"
|
#include "FloatNode.h"
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
struct CloudSegment {
|
struct CloudSegment {
|
||||||
Vector3 start;
|
Vector3 start;
|
||||||
Vector3 end;
|
Vector3 end;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "OverlayRasterizer.h"
|
#include "OverlayRasterizer.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "CameraDefinition.h"
|
#include "CameraDefinition.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Rasterizer.h"
|
#include "Rasterizer.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "CameraDefinition.h"
|
#include "CameraDefinition.h"
|
||||||
#include "CanvasPortion.h"
|
#include "CanvasPortion.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "SkyRasterizer.h"
|
#include "SkyRasterizer.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
#include "Color.h"
|
#include "Color.h"
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "TerrainRasterizer.h"
|
#include "TerrainRasterizer.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "BoundingBox.h"
|
#include "BoundingBox.h"
|
||||||
#include "CameraDefinition.h"
|
#include "CameraDefinition.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "TerrainRayWalker.h"
|
#include "TerrainRayWalker.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "TerrainDefinition.h"
|
#include "TerrainDefinition.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "TexturesRenderer.h"
|
#include "TexturesRenderer.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "TextureLayerDefinition.h"
|
#include "TextureLayerDefinition.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "WaterRasterizer.h"
|
#include "WaterRasterizer.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "WaterRenderer.h"
|
#include "WaterRenderer.h"
|
||||||
#include "CanvasFragment.h"
|
#include "CanvasFragment.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "WaterRenderer.h"
|
#include "WaterRenderer.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "SoftwareRenderer.h"
|
#include "SoftwareRenderer.h"
|
||||||
#include "TerrainRenderer.h"
|
#include "TerrainRenderer.h"
|
||||||
#include "WaterDefinition.h"
|
#include "WaterDefinition.h"
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace system {
|
||||||
/**
|
/**
|
||||||
* Logger streams
|
* Logger streams
|
||||||
*/
|
*/
|
||||||
class Logs {
|
class SYSTEMSHARED_EXPORT Logs {
|
||||||
public:
|
public:
|
||||||
static std::ostream &debug();
|
static std::ostream &debug();
|
||||||
static std::ostream &warning();
|
static std::ostream &warning();
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#define Q_DECL_EXPORT __declspec(dllexport)
|
#define Q_DECL_EXPORT __declspec(dllexport)
|
||||||
#define Q_DECL_IMPORT __declspec(dllimport)
|
#define Q_DECL_IMPORT __declspec(dllimport)
|
||||||
#else
|
#else
|
||||||
#define PAYSAGES_USE_INLINING 1
|
|
||||||
#define Q_DECL_EXPORT __attribute__((visibility("default")))
|
#define Q_DECL_EXPORT __attribute__((visibility("default")))
|
||||||
#define Q_DECL_IMPORT __attribute__((visibility("default")))
|
#define Q_DECL_IMPORT __attribute__((visibility("default")))
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "BaseTestCase.h"
|
#include "BaseTestCase.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "CappedCylinder.h"
|
#include "CappedCylinder.h"
|
||||||
|
|
||||||
TEST(CappedCylinder, findRayIntersection) {
|
TEST(CappedCylinder, findRayIntersection) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "BaseTestCase.h"
|
#include "BaseTestCase.h"
|
||||||
#include "GodRaysSampler.h"
|
#include "GodRaysSampler.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include "SpaceSegment.h"
|
#include "SpaceSegment.h"
|
||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
#include "LightingManager.h"
|
#include "LightingManager.h"
|
||||||
|
|
Loading…
Reference in a new issue