Freeze and disable fluid medium traversal, for master merge of progress
This commit is contained in:
parent
5054d3583d
commit
f1a13516c9
35 changed files with 403 additions and 153 deletions
4
Makefile
4
Makefile
|
@ -33,7 +33,11 @@ release:
|
|||
+make BUILDMODE=release all
|
||||
|
||||
tests:build
|
||||
ifdef TESTCASE
|
||||
LD_LIBRARY_PATH=$(LIBRARY_PATH) ${BUILDPATH}/tests/paysages-tests --gtest_filter=$(TESTCASE).*
|
||||
else
|
||||
LD_LIBRARY_PATH=$(LIBRARY_PATH) ${BUILDPATH}/tests/paysages-tests
|
||||
endif
|
||||
|
||||
run_cli:build
|
||||
LD_LIBRARY_PATH=$(LIBRARY_PATH) ${RUNNER} ${BUILDPATH}/controlling/paysages-cli
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "SpaceCoordinates.h"
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef SPACECOORDINATES_H
|
||||
#define SPACECOORDINATES_H
|
||||
|
||||
#include "basics_global.h"
|
||||
|
||||
#include "Vector3.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace basics {
|
||||
|
||||
/*!
|
||||
* \brief Space 3D coordinates.
|
||||
*
|
||||
* These coordinates allow to work on very large scenes, regardless of the 'double' type precision.
|
||||
*/
|
||||
class SpaceCoordinates:public Vector3
|
||||
{
|
||||
/*public:
|
||||
SpaceCoordinates();*/
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPACECOORDINATES_H
|
56
src/basics/SpaceSegment.cpp
Normal file
56
src/basics/SpaceSegment.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "SpaceSegment.h"
|
||||
|
||||
SpaceSegment::SpaceSegment(const Vector3& start, const Vector3& end):
|
||||
start(start), end(end)
|
||||
{
|
||||
}
|
||||
|
||||
bool SpaceSegment::intersectYInterval(double ymin, double ymax)
|
||||
{
|
||||
if (start.y > ymax)
|
||||
{
|
||||
if (end.y >= ymax)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 diff = end.sub(start);
|
||||
start = start.add(diff.scale((ymax - start.y) / diff.y));
|
||||
if (end.y < ymin)
|
||||
{
|
||||
end = end.add(diff.scale((ymin - end.y) / diff.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (start.y < ymin)
|
||||
{
|
||||
if (end.y <= ymin)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 diff = end.sub(start);
|
||||
start = start.add(diff.scale((ymin - start.y) / diff.y));
|
||||
if (end.y >= ymax)
|
||||
{
|
||||
end = end.add(diff.scale((ymax - end.y) / diff.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* start is inside layer */
|
||||
{
|
||||
Vector3 diff = end.sub(start);
|
||||
if (end.y > ymax)
|
||||
{
|
||||
end = start.add(diff.scale((ymax - start.y) / diff.y));
|
||||
}
|
||||
else if (end.y < ymin)
|
||||
{
|
||||
end = start.add(diff.scale((ymin - start.y) / diff.y));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
39
src/basics/SpaceSegment.h
Normal file
39
src/basics/SpaceSegment.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef SPACESEGMENT_H
|
||||
#define SPACESEGMENT_H
|
||||
|
||||
#include "basics_global.h"
|
||||
|
||||
#include "Vector3.h"
|
||||
|
||||
namespace paysages
|
||||
{
|
||||
namespace basics
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief A segment in 3D space (mainly useful for rays).
|
||||
*/
|
||||
class SpaceSegment
|
||||
{
|
||||
public:
|
||||
SpaceSegment(const Vector3& start, const Vector3& end);
|
||||
SpaceSegment(): SpaceSegment(Vector3(), Vector3()) {}
|
||||
|
||||
inline Vector3 getStart() const {return start;}
|
||||
inline Vector3 getEnd() const {return end;}
|
||||
|
||||
/*!
|
||||
* \brief Keep only the intersection with a slice orthogonal to the Y axis.
|
||||
* \return true if a segment remains
|
||||
*/
|
||||
bool intersectYInterval(double ymin, double ymax);
|
||||
|
||||
private:
|
||||
Vector3 start;
|
||||
Vector3 end;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPACESEGMENT_H
|
|
@ -19,9 +19,9 @@ SOURCES += \
|
|||
NoiseFunctionPerlin.cpp \
|
||||
NoiseFunctionSimplex.cpp \
|
||||
Interpolation.cpp \
|
||||
SpaceCoordinates.cpp \
|
||||
Vector3.cpp \
|
||||
Vector3.inline.cpp
|
||||
Vector3.inline.cpp \
|
||||
SpaceSegment.cpp
|
||||
|
||||
HEADERS +=\
|
||||
basics_global.h \
|
||||
|
@ -30,8 +30,8 @@ HEADERS +=\
|
|||
NoiseFunctionPerlin.h \
|
||||
NoiseFunctionSimplex.h \
|
||||
Interpolation.h \
|
||||
SpaceCoordinates.h \
|
||||
Vector3.h
|
||||
Vector3.h \
|
||||
SpaceSegment.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace paysages {
|
||||
namespace basics {
|
||||
class Vector3;
|
||||
class SpaceSegment;
|
||||
}
|
||||
}
|
||||
using namespace paysages::basics;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
CONFIG(release, debug|release): DEFINES += NDEBUG
|
||||
|
||||
QMAKE_CXXFLAGS = -std=c++11
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
#include "software_global.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace basics {
|
||||
class SpaceCoordinate;
|
||||
}
|
||||
namespace software {
|
||||
|
||||
/*!
|
||||
|
@ -16,9 +13,10 @@ class SOFTWARESHARED_EXPORT FluidMediumInterface
|
|||
{
|
||||
public:
|
||||
/*!
|
||||
* Return true if the object may interfere with the fluid medium on the given segment.
|
||||
* Return true if the object may change the fluid medium on the given segment.
|
||||
* When returning true, the object may alter 'segment' to limit its influence.
|
||||
*/
|
||||
virtual bool mayInfluence(const SpaceCoordinate& start, const SpaceCoordinate& end) const = 0;
|
||||
virtual bool checkInfluence(SpaceSegment& segment) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
51
src/render/software/FluidMediumManager.cpp
Normal file
51
src/render/software/FluidMediumManager.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include "FluidMediumManager.h"
|
||||
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "FluidMediumInterface.h"
|
||||
|
||||
FluidMediumManager::FluidMediumManager(SoftwareRenderer* renderer):
|
||||
renderer(renderer)
|
||||
{
|
||||
}
|
||||
|
||||
FluidMediumManager::~FluidMediumManager()
|
||||
{
|
||||
}
|
||||
|
||||
void FluidMediumManager::clearMedia()
|
||||
{
|
||||
media.clear();
|
||||
}
|
||||
|
||||
void FluidMediumManager::registerMedium(FluidMediumInterface *medium)
|
||||
{
|
||||
media.push_back(medium);
|
||||
}
|
||||
|
||||
Color FluidMediumManager::applyTraversal(const Vector3 &eye, const Vector3 &location, const Color &color) const
|
||||
{
|
||||
// Collect potential segments
|
||||
SpaceSegment ray(eye, location);
|
||||
int max_segments = media.size();
|
||||
FluidMediumSegment* segments;
|
||||
segments = new FluidMediumSegment[max_segments];
|
||||
int segment_count = getTraversedMedia(segments, ray, max_segments);
|
||||
|
||||
delete[] segments;
|
||||
return color;
|
||||
}
|
||||
|
||||
int FluidMediumManager::getTraversedMedia(FluidMediumSegment segments[], const SpaceSegment &ray, int max_segments) const
|
||||
{
|
||||
int added = 0;
|
||||
for (auto &medium : media)
|
||||
{
|
||||
SpaceSegment ray_inter(ray);
|
||||
if (added < max_segments and medium->checkInfluence(ray_inter))
|
||||
{
|
||||
// The medium intersect with the ray
|
||||
segments[added++] = {medium, ray_inter};
|
||||
}
|
||||
}
|
||||
return added;
|
||||
}
|
62
src/render/software/FluidMediumManager.h
Normal file
62
src/render/software/FluidMediumManager.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
#ifndef FLUIDMEDIUMMANAGER_H
|
||||
#define FLUIDMEDIUMMANAGER_H
|
||||
|
||||
#include "software_global.h"
|
||||
|
||||
#include "SpaceSegment.h"
|
||||
#include "tools/color.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace software {
|
||||
|
||||
typedef struct {
|
||||
FluidMediumInterface* medium;
|
||||
SpaceSegment segment;
|
||||
} FluidMediumSegment;
|
||||
|
||||
/*!
|
||||
* \brief Global object to interact with fluid medium (air, water, clouds...)
|
||||
*
|
||||
* This object handles the traversal of fluid medium and the collecting of
|
||||
* medium density and properties.
|
||||
* It is mainly used to compute the alteration made by such media on light.
|
||||
*/
|
||||
class SOFTWARESHARED_EXPORT FluidMediumManager
|
||||
{
|
||||
public:
|
||||
FluidMediumManager(SoftwareRenderer *renderer);
|
||||
virtual ~FluidMediumManager();
|
||||
|
||||
/*!
|
||||
* \brief Remove all registered medium.
|
||||
*/
|
||||
void clearMedia();
|
||||
|
||||
/*!
|
||||
* \brief Register a new medium in the manager.
|
||||
*/
|
||||
void registerMedium(FluidMediumInterface *medium);
|
||||
|
||||
/*!
|
||||
* \brief Apply complete medium traversal
|
||||
* \param eye Position of the camera
|
||||
* \param location Point we look at
|
||||
* \param color Light initially received from 'location'
|
||||
* \return Light received by 'eye', transformed by medium traversal
|
||||
*/
|
||||
virtual Color applyTraversal(const Vector3 &eye, const Vector3 &location, const Color &color) const;
|
||||
|
||||
/*!
|
||||
* \brief Get the potential media traversed by a ray, unsorted
|
||||
*/
|
||||
virtual int getTraversedMedia(FluidMediumSegment segments[], const SpaceSegment &ray, int max_segments) const;
|
||||
|
||||
private:
|
||||
SoftwareRenderer *renderer;
|
||||
std::vector<FluidMediumInterface*> media;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FLUIDMEDIUMTRAVERSAL_H
|
|
@ -1,26 +0,0 @@
|
|||
#include "FluidMediumTraversal.h"
|
||||
|
||||
FluidMediumTraversal::FluidMediumTraversal(SoftwareRenderer* renderer):
|
||||
renderer(renderer)
|
||||
{
|
||||
}
|
||||
|
||||
FluidMediumTraversal::~FluidMediumTraversal()
|
||||
{
|
||||
}
|
||||
|
||||
void FluidMediumTraversal::setCollector(FluidMediumCollector *collector)
|
||||
{
|
||||
}
|
||||
|
||||
void FluidMediumTraversal::getTraversedMedia(std::vector<FluidMediumInterface> &media, const SpaceCoordinates &start, const SpaceCoordinates &end)
|
||||
{
|
||||
}
|
||||
|
||||
void FluidMediumTraversal::collectHalfLine(const SpaceCoordinates &start, const Vector3 &direction)
|
||||
{
|
||||
}
|
||||
|
||||
void FluidMediumTraversal::collectSegment(const SpaceCoordinates &start, const SpaceCoordinates &end)
|
||||
{
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef FLUIDMEDIUMTRAVERSAL_H
|
||||
#define FLUIDMEDIUMTRAVERSAL_H
|
||||
|
||||
#include "software_global.h"
|
||||
|
||||
#include <vector>
|
||||
#include "SpaceCoordinates.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace software {
|
||||
|
||||
class SoftwareRenderer;
|
||||
class FluidMediumCollector;
|
||||
class FluidMediumInterface;
|
||||
|
||||
/*!
|
||||
* \brief Global object to interact with fluid medium (air, water, clouds...)
|
||||
*
|
||||
* This object handles the traversal of fluid medium and the collecting of
|
||||
* medium density and properties.
|
||||
* It is mainly used to compute the alteration made by such media on light.
|
||||
*/
|
||||
class SOFTWARESHARED_EXPORT FluidMediumTraversal
|
||||
{
|
||||
public:
|
||||
FluidMediumTraversal(SoftwareRenderer *renderer);
|
||||
virtual ~FluidMediumTraversal();
|
||||
|
||||
void setCollector(FluidMediumCollector *collector);
|
||||
|
||||
virtual void getTraversedMedia(std::vector<FluidMediumInterface> &media, const SpaceCoordinates &start, const SpaceCoordinates &end);
|
||||
|
||||
void collectHalfLine(const SpaceCoordinates &start, const Vector3 &direction);
|
||||
void collectSegment(const SpaceCoordinates &start, const SpaceCoordinates &end);
|
||||
|
||||
private:
|
||||
SoftwareRenderer* renderer;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FLUIDMEDIUMTRAVERSAL_H
|
|
@ -1,11 +1,12 @@
|
|||
#include "SoftwareRenderer.h"
|
||||
|
||||
#include "camera.h"
|
||||
#include "Scenery.h"
|
||||
#include "FluidMediumTraversal.h"
|
||||
#include "FluidMediumManager.h"
|
||||
|
||||
SoftwareRenderer::SoftwareRenderer(Scenery* scenery)
|
||||
{
|
||||
fluid_medium = new FluidMediumTraversal(this);
|
||||
fluid_medium = new FluidMediumManager(this);
|
||||
|
||||
if (scenery)
|
||||
{
|
||||
|
@ -23,8 +24,13 @@ SoftwareRenderer::~SoftwareRenderer()
|
|||
delete fluid_medium;
|
||||
}
|
||||
|
||||
Color SoftwareRenderer::applyMediumTraversal(Vector3 location, Color color)
|
||||
void SoftwareRenderer::initialize()
|
||||
{
|
||||
// TODO
|
||||
return color;
|
||||
//fluid_medium->registerMedium(water_renderer);
|
||||
}
|
||||
|
||||
/*Color SoftwareRenderer::applyMediumTraversal(Vector3 location, Color color)
|
||||
{
|
||||
Vector3 eye = cameraGetLocation(scenery->getCamera());
|
||||
return fluid_medium->applyTraversal(eye, location, color);
|
||||
}*/
|
||||
|
|
|
@ -10,8 +10,6 @@ class Scenery;
|
|||
namespace paysages {
|
||||
namespace software {
|
||||
|
||||
class FluidMediumTraversal;
|
||||
|
||||
/*!
|
||||
* \brief This class renders a defined scenery in sotware mode (using only standard CPU computations).
|
||||
*/
|
||||
|
@ -22,13 +20,16 @@ public:
|
|||
SoftwareRenderer(Scenery* scenery=0);
|
||||
virtual ~SoftwareRenderer();
|
||||
|
||||
inline Scenery* getScenery() const {return scenery;}
|
||||
virtual void initialize();
|
||||
|
||||
virtual Color applyMediumTraversal(Vector3 location, Color color);
|
||||
inline Scenery* getScenery() const {return scenery;}
|
||||
inline FluidMediumManager* getFluidMediumManager() const {return fluid_medium;}
|
||||
|
||||
//virtual Color applyMediumTraversal(Vector3 location, Color color) override;
|
||||
|
||||
private:
|
||||
Scenery* scenery;
|
||||
FluidMediumTraversal* fluid_medium;
|
||||
FluidMediumManager* fluid_medium;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ DEFINES += SOFTWARE_LIBRARY
|
|||
include(../../common.pri)
|
||||
|
||||
SOURCES += SoftwareRenderer.cpp \
|
||||
FluidMediumTraversal.cpp \
|
||||
FluidMediumInterface.cpp
|
||||
FluidMediumInterface.cpp \
|
||||
FluidMediumManager.cpp
|
||||
|
||||
HEADERS += SoftwareRenderer.h\
|
||||
software_global.h \
|
||||
FluidMediumTraversal.h \
|
||||
FluidMediumInterface.h
|
||||
FluidMediumInterface.h \
|
||||
FluidMediumManager.h
|
||||
|
||||
unix:!symbian {
|
||||
maemo5 {
|
||||
|
|
|
@ -9,14 +9,17 @@
|
|||
# define SOFTWARESHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#include "basics_global.h"
|
||||
|
||||
namespace paysages {
|
||||
namespace basics {}
|
||||
namespace definition {}
|
||||
namespace software {}
|
||||
namespace software {
|
||||
class SoftwareRenderer;
|
||||
class FluidMediumManager;
|
||||
class FluidMediumInterface;
|
||||
class FluidMediumCollector;
|
||||
}
|
||||
}
|
||||
|
||||
using namespace paysages::basics;
|
||||
using namespace paysages::definition;
|
||||
using namespace paysages::software;
|
||||
|
||||
#endif // SOFTWARE_GLOBAL_H
|
||||
|
|
|
@ -51,7 +51,7 @@ static Mount MOUNTS[MOUNTS_COUNT] = {
|
|||
};
|
||||
|
||||
static SurfaceMaterial MOUNT_MATERIAL = {
|
||||
{0.4, 0.4, 0.4, 1.0}, 0.0, 0.0
|
||||
{0.4, 0.4, 0.4, 1.0}, 0.0, 0.0, 0.0, 0.0, {0.0, 0.0, 0.0, 0.0}
|
||||
};
|
||||
|
||||
static inline int _rayIntersectsTriangle(Vector3 p, Vector3 d, Vector3 v0, Vector3 v1, Vector3 v2, Vector3* hit)
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
#include "rendering/terrain/public.h"
|
||||
#include "rendering/water/public.h"
|
||||
|
||||
struct CameraDefinition
|
||||
class CameraDefinition
|
||||
{
|
||||
public:
|
||||
/* Definition */
|
||||
Vector3 location;
|
||||
VectorSpherical direction;
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace paysages {
|
|||
namespace system {class PackStream;}
|
||||
}
|
||||
|
||||
typedef struct CameraDefinition CameraDefinition;
|
||||
class CameraDefinition;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "tools/color.h"
|
||||
#include "tools/euclid.h"
|
||||
|
||||
typedef Color (*f_RenderFragmentCallback)(struct Renderer* renderer, Vector3 location, void* data);
|
||||
typedef Color (*f_RenderFragmentCallback)(Renderer* renderer, Vector3 location, void* data);
|
||||
|
||||
typedef void (*RenderCallbackStart)(int width, int height, Color background);
|
||||
typedef void (*RenderCallbackDraw)(int x, int y, Color col);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "rendering/textures/public.h"
|
||||
#include "rendering/water/public.h"
|
||||
|
||||
static RayCastingResult _RAYCASTING_NULL = {0};
|
||||
static RayCastingResult _RAYCASTING_NULL = {0, {0.0, 0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}};
|
||||
|
||||
static void* _renderFirstPass(void* data)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "../tools/euclid.h"
|
||||
#include "../tools/color.h"
|
||||
|
||||
typedef struct Renderer Renderer;
|
||||
class Renderer;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -144,7 +144,7 @@ static Color _fakeGetFinalColor(Renderer* renderer, Vector3 location, double pre
|
|||
return COLOR_GREEN;
|
||||
}
|
||||
|
||||
static Color _realGetFinalColor(Renderer* renderer, Vector3 location, double precision)
|
||||
static Color _realGetFinalColor(Renderer* renderer, Vector3 location, double)
|
||||
{
|
||||
/* TODO Restore precision control */
|
||||
TexturesResult textures = renderer->textures->applyToTerrain(renderer, location.x, location.z);
|
||||
|
|
|
@ -6,16 +6,18 @@
|
|||
|
||||
void* naiveArrayInsert(void** array, size_t item_size, int item_count, int location)
|
||||
{
|
||||
char** barray = (char**)array;
|
||||
|
||||
assert(location >= 0);
|
||||
assert(location <= item_count);
|
||||
|
||||
*array = realloc(*array, item_size * (item_count + 1));
|
||||
*barray = (char*)realloc(*barray, item_size * (item_count + 1));
|
||||
if (location < item_count)
|
||||
{
|
||||
memmove(*array + item_size * (location + 1), *array + item_size * location, item_size * (item_count - location));
|
||||
memmove(*barray + item_size * (location + 1), *barray + item_size * location, item_size * (item_count - location));
|
||||
}
|
||||
|
||||
return *array + item_size * location;
|
||||
return *barray + item_size * location;
|
||||
}
|
||||
|
||||
void arrayCreate(Array* array, int item_size)
|
||||
|
@ -35,7 +37,7 @@ void arrayDelete(Array* array)
|
|||
|
||||
void* arrayAppend(Array* array, void* item)
|
||||
{
|
||||
void* dest;
|
||||
char* dest;
|
||||
size_t item_size = (size_t)array->item_size;
|
||||
|
||||
if (array->length >= array->alloc_length)
|
||||
|
@ -44,7 +46,7 @@ void* arrayAppend(Array* array, void* item)
|
|||
array->data = realloc(array->data, item_size * array->alloc_length);
|
||||
}
|
||||
|
||||
dest = array->data + item_size * array->length;
|
||||
dest = ((char*)array->data) + item_size * array->length;
|
||||
memcpy(dest, item, item_size);
|
||||
array->length++;
|
||||
|
||||
|
@ -56,7 +58,7 @@ void* arrayAppend(Array* array, void* item)
|
|||
void arrayInsert(Array* array, void* item, int position)
|
||||
{
|
||||
size_t item_size;
|
||||
void* dest;
|
||||
char* dest;
|
||||
|
||||
if (position >= array->length)
|
||||
{
|
||||
|
@ -72,9 +74,9 @@ void arrayInsert(Array* array, void* item, int position)
|
|||
array->data = realloc(array->data, item_size * array->alloc_length);
|
||||
}
|
||||
|
||||
dest = array->data + item_size * position;
|
||||
dest = ((char*)array->data) + item_size * position;
|
||||
memmove(dest + item_size, dest, array->length - position);
|
||||
memcpy(array->data + item_size * position, item, item_size);
|
||||
memcpy(((char*)array->data) + item_size * position, item, item_size);
|
||||
array->length++;
|
||||
|
||||
array->dirty = 1;
|
||||
|
@ -88,7 +90,7 @@ void arrayReplace(Array* array, void* item, int position)
|
|||
if (position >= 0 && position < array->length)
|
||||
{
|
||||
item_size = (size_t)array->item_size;
|
||||
memcpy(array->data + item_size * position, item, item_size);
|
||||
memcpy(((char*)array->data) + item_size * position, item, item_size);
|
||||
|
||||
array->dirty = 1;
|
||||
}
|
||||
|
@ -105,7 +107,7 @@ void arrayLStrip(Array* array, int count)
|
|||
else if (count >= 0)
|
||||
{
|
||||
item_size = (size_t)array->item_size;
|
||||
memmove(array->data, array->data + item_size * count, item_size * (array->length - count));
|
||||
memmove(array->data, ((char*)array->data) + item_size * count, item_size * (array->length - count));
|
||||
array->length -= count;
|
||||
array->dirty = 1;
|
||||
}
|
||||
|
|
|
@ -212,8 +212,9 @@ void colorLimitPower(Color* col, double max_power)
|
|||
}
|
||||
|
||||
/******************************** ColorProfile ********************************/
|
||||
struct ColorProfile
|
||||
class ColorProfile
|
||||
{
|
||||
public:
|
||||
double minvalue;
|
||||
double maxvalue;
|
||||
Color(*mapper)(Color col, double exposure);
|
||||
|
@ -297,12 +298,12 @@ void colorProfileSetToneMapping(ColorProfile* profile, ToneMappingOperator tonem
|
|||
profile->exposure = exposure;
|
||||
}
|
||||
|
||||
void colorProfileSave(PackStream* stream, ColorProfile* profile)
|
||||
void colorProfileSave(PackStream*, ColorProfile*)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void colorProfileLoad(PackStream* stream, ColorProfile* profile)
|
||||
void colorProfileLoad(PackStream*, ColorProfile*)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ RENDERINGSHARED_EXPORT double colorGetPower(Color* col);
|
|||
RENDERINGSHARED_EXPORT void colorLimitPower(Color* col, double max_power);
|
||||
|
||||
/* HDR profile for tone-mapping */
|
||||
typedef struct ColorProfile ColorProfile;
|
||||
class ColorProfile;
|
||||
typedef enum
|
||||
{
|
||||
TONE_MAPPING_UNCHARTED,
|
||||
|
|
|
@ -15,8 +15,9 @@ typedef struct
|
|||
void* data;
|
||||
} LightFilterCallback;
|
||||
|
||||
struct LightingManager
|
||||
class LightingManager
|
||||
{
|
||||
public:
|
||||
int specularity_enabled;
|
||||
int callbacks_count;
|
||||
LightFilterCallback callbacks[MAX_CALLBACK_COUNT];
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef struct
|
|||
|
||||
typedef int (*FuncLightingAlterLight)(void* data, LightDefinition* light, Vector3 at);
|
||||
|
||||
typedef struct LightingManager LightingManager;
|
||||
class LightingManager;
|
||||
typedef struct LightStatus LightStatus;
|
||||
|
||||
RENDERINGSHARED_EXPORT LightingManager* lightingManagerCreate();
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void* memory2dRealloc(void* data, int datasize, int oldxsize, int oldysize, int newxsize, int newysize, int xoffset, int yoffset)
|
||||
char* memory2dRealloc(char* data, int datasize, int oldxsize, int oldysize, int newxsize, int newysize, int xoffset, int yoffset)
|
||||
{
|
||||
int xstart, xend, xlen;
|
||||
int ystart, yend, y;
|
||||
void* result = malloc(datasize * newxsize * newysize);
|
||||
char* result = (char*)malloc(datasize * newxsize * newysize);
|
||||
|
||||
/* Move remaining part*/
|
||||
ystart = yoffset;
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
|
||||
#include "../rendering_global.h"
|
||||
|
||||
RENDERINGSHARED_EXPORT void* memory2dRealloc(void* data, int datasize, int oldxsize, int oldysize, int newxsize, int newysize, int xoffset, int yoffset);
|
||||
RENDERINGSHARED_EXPORT char* memory2dRealloc(char* data, int datasize, int oldxsize, int oldysize, int newxsize, int newysize, int xoffset, int yoffset);
|
||||
|
||||
#endif
|
||||
|
|
110
src/tests/FluidMediumManager_Test.cpp
Normal file
110
src/tests/FluidMediumManager_Test.cpp
Normal file
|
@ -0,0 +1,110 @@
|
|||
#include "BaseTestCase.h"
|
||||
|
||||
#include "SpaceSegment.h"
|
||||
#include "Scenery.h"
|
||||
#include "SoftwareRenderer.h"
|
||||
#include "FluidMediumManager.h"
|
||||
#include "FluidMediumInterface.h"
|
||||
|
||||
class FluidMediumManager_Test:public BaseTestCase
|
||||
{
|
||||
protected:
|
||||
virtual void setUp()
|
||||
{
|
||||
scenery = new Scenery();
|
||||
renderer = new SoftwareRenderer(scenery);
|
||||
}
|
||||
|
||||
virtual void tearDown()
|
||||
{
|
||||
delete renderer;
|
||||
delete scenery;
|
||||
}
|
||||
|
||||
Scenery* scenery;
|
||||
SoftwareRenderer* renderer;
|
||||
};
|
||||
|
||||
|
||||
TEST_F(FluidMediumManager_Test, getTraversedMedia)
|
||||
{
|
||||
FluidMediumManager manager(renderer);
|
||||
int traversed;
|
||||
FluidMediumSegment segments[10];
|
||||
class FakeMedium:public FluidMediumInterface
|
||||
{
|
||||
public:
|
||||
void setCut(double ymin, double ymax)
|
||||
{
|
||||
this->ymin = ymin;
|
||||
this->ymax = ymax;
|
||||
}
|
||||
|
||||
virtual bool checkInfluence(SpaceSegment& segment) const override
|
||||
{
|
||||
return segment.intersectYInterval(this->ymin, this->ymax);
|
||||
}
|
||||
private:
|
||||
double ymin = -2.0;
|
||||
double ymax = -1.0;
|
||||
};
|
||||
SpaceSegment ray(Vector3(0.0, 0.0, 0.0), Vector3(8.0, 10.0, -4.0));
|
||||
|
||||
// Empty manager
|
||||
traversed = manager.getTraversedMedia(segments, ray, 10);
|
||||
ASSERT_EQ(0, traversed);
|
||||
|
||||
// Testing with 1 medium outside the range
|
||||
FakeMedium m1;
|
||||
manager.registerMedium(&m1);
|
||||
traversed = manager.getTraversedMedia(segments, ray, 10);
|
||||
ASSERT_EQ(0, traversed);
|
||||
|
||||
// Setting the medium in range
|
||||
m1.setCut(1.0, 2.0);
|
||||
traversed = manager.getTraversedMedia(segments, ray, 10);
|
||||
ASSERT_EQ(1, traversed);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m1, segments[0].medium);
|
||||
EXPECT_VECTOR3_COORDS(segments[0].segment.getStart(), 0.8, 1.0, -0.4);
|
||||
EXPECT_VECTOR3_COORDS(segments[0].segment.getEnd(), 1.6, 2.0, -0.8);
|
||||
|
||||
// Testing with 2 media
|
||||
FakeMedium m2;
|
||||
m2.setCut(4.0, 12.0);
|
||||
manager.registerMedium(&m2);
|
||||
traversed = manager.getTraversedMedia(segments, ray, 10);
|
||||
ASSERT_EQ(2, traversed);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m1, segments[0].medium);
|
||||
EXPECT_VECTOR3_COORDS(segments[0].segment.getStart(), 0.8, 1.0, -0.4);
|
||||
EXPECT_VECTOR3_COORDS(segments[0].segment.getEnd(), 1.6, 2.0, -0.8);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m2, segments[1].medium);
|
||||
EXPECT_VECTOR3_COORDS(segments[1].segment.getStart(), 3.2, 4.0, -1.6);
|
||||
EXPECT_VECTOR3_COORDS(segments[1].segment.getEnd(), 8.0, 10.0, -4.0);
|
||||
|
||||
// Testing with overlapping media
|
||||
FakeMedium m3;
|
||||
m3.setCut(3.0, 4.5);
|
||||
manager.registerMedium(&m3);
|
||||
traversed = manager.getTraversedMedia(segments, ray, 10);
|
||||
ASSERT_EQ(3, traversed);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m1, segments[0].medium);
|
||||
EXPECT_VECTOR3_COORDS(segments[0].segment.getStart(), 0.8, 1.0, -0.4);
|
||||
EXPECT_VECTOR3_COORDS(segments[0].segment.getEnd(), 1.6, 2.0, -0.8);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m2, segments[1].medium);
|
||||
EXPECT_VECTOR3_COORDS(segments[1].segment.getStart(), 3.2, 4.0, -1.6);
|
||||
EXPECT_VECTOR3_COORDS(segments[1].segment.getEnd(), 8.0, 10.0, -4.0);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m3, segments[2].medium);
|
||||
EXPECT_VECTOR3_COORDS(segments[2].segment.getStart(), 2.4, 3.0, -1.2);
|
||||
EXPECT_VECTOR3_COORDS(segments[2].segment.getEnd(), 3.6, 4.5, -1.8);
|
||||
|
||||
// Testing the segment count limit
|
||||
traversed = manager.getTraversedMedia(segments, ray, 2);
|
||||
ASSERT_EQ(2, traversed);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m1, segments[0].medium);
|
||||
EXPECT_EQ((FluidMediumInterface*)&m2, segments[1].medium);
|
||||
|
||||
// Testing after clear
|
||||
manager.clearMedia();
|
||||
traversed = manager.getTraversedMedia(segments, ray, 10);
|
||||
ASSERT_EQ(0, traversed);
|
||||
}
|
|
@ -8,7 +8,7 @@ TEST(PackStream, All)
|
|||
int i;
|
||||
int data_i;
|
||||
double data_d;
|
||||
char* data_s;
|
||||
const char* data_s;
|
||||
char buffer[100];
|
||||
|
||||
/* Writing to pack */
|
||||
|
|
|
@ -11,7 +11,7 @@ TEMPLATE = lib
|
|||
|
||||
DEFINES += GOOGLETEST_LIBRARY
|
||||
|
||||
#QMAKE_CXXFLAGS += -pthread
|
||||
QMAKE_CXXFLAGS += -pthread -Wno-missing-field-initializers
|
||||
|
||||
INCLUDEPATH += . ./include
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ CONFIG -= app_bundle
|
|||
|
||||
TARGET = paysages-tests
|
||||
|
||||
include(../common.pri)
|
||||
|
||||
SOURCES += main.cpp \
|
||||
Layers_Test.cpp \
|
||||
PackStream_Test.cpp \
|
||||
|
@ -14,7 +16,8 @@ SOURCES += main.cpp \
|
|||
Euclid_Test.cpp \
|
||||
Bruneton_Test.cpp \
|
||||
Camera_Test.cpp \
|
||||
Clouds_Test.cpp
|
||||
Clouds_Test.cpp \
|
||||
FluidMediumManager_Test.cpp
|
||||
|
||||
HEADERS += \
|
||||
BaseTestCase.h
|
||||
|
@ -48,3 +51,9 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rendering/debug/
|
|||
else:unix: LIBS += -L$$OUT_PWD/../rendering/ -lpaysages_rendering
|
||||
INCLUDEPATH += $$PWD/../rendering
|
||||
DEPENDPATH += $$PWD/../rendering
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/software/release/ -lpaysages_render_software
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/software/debug/ -lpaysages_render_software
|
||||
else:unix: LIBS += -L$$OUT_PWD/../render/software/ -lpaysages_render_software
|
||||
INCLUDEPATH += $$PWD/../render/software
|
||||
DEPENDPATH += $$PWD/../render/software
|
||||
|
|
Loading…
Reference in a new issue