paysages : Switch all doubles to floats (for memory consumption) + added render timer.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@348 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
294dc62156
commit
ee86e2d251
80 changed files with 865 additions and 827 deletions
|
@ -16,10 +16,12 @@ Scenery :
|
|||
|
||||
Rendering :
|
||||
* New texture model (perpendicular displacement and thickness).
|
||||
* Added full scene antialiasing (FSAA).
|
||||
|
||||
GUI :
|
||||
* Improved curve rendering.
|
||||
* New material editor.
|
||||
* Added render timer.
|
||||
|
||||
Misc :
|
||||
* Version handling in saved files.
|
||||
|
|
1
TODO
1
TODO
|
@ -14,7 +14,6 @@ Technology Preview 2 :
|
|||
- Add a terrain modifier dialog with zones.
|
||||
- Use the curve editor in noise editor
|
||||
- Add a noise filler (and maybe noise intervals ?).
|
||||
- Add a popup when rendering is complete (with stats), except for quick render.
|
||||
- Optimize the use of noiseGetMaxValue (limit its use or cache it).
|
||||
- Fix the distorted sun appearance.
|
||||
- Improve curve editor.
|
||||
|
|
|
@ -31,7 +31,7 @@ void displayHelp()
|
|||
printf(" -ds x Day step time (float)\n");
|
||||
}
|
||||
|
||||
void _previewUpdate(double progress)
|
||||
void _previewUpdate(float progress)
|
||||
{
|
||||
printf("\rProgress : %0.1f%% ", progress * 100.0);
|
||||
fflush(stdout);
|
||||
|
@ -43,8 +43,8 @@ int main(int argc, char** argv)
|
|||
char* conf_file_path = NULL;
|
||||
RenderParams conf_render_params = {800, 600, 1, 5};
|
||||
int conf_nb_pictures = 1;
|
||||
double conf_daytime_start = 0.4;
|
||||
double conf_daytime_step = 0.0;
|
||||
float conf_daytime_start = 0.4;
|
||||
float conf_daytime_step = 0.0;
|
||||
int outputcount;
|
||||
char outputpath[500];
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ bool BaseExplorerChunk::maintain()
|
|||
{
|
||||
if (_texture_current_size <= 1 || i % 2 != 0 || j % 2 != 0)
|
||||
{
|
||||
Color color = getTextureColor((double)i / (double)new_texture_size, 1.0 - (double)j / (double)new_texture_size);
|
||||
Color color = getTextureColor((float)i / (float)new_texture_size, 1.0 - (float)j / (float)new_texture_size);
|
||||
new_image->setPixel(i, j, colorTo32BitBGRA(&color));
|
||||
}
|
||||
}
|
||||
|
@ -139,12 +139,12 @@ void BaseExplorerChunk::onRenderEvent(QGLWidget* widget)
|
|||
{
|
||||
}
|
||||
|
||||
double BaseExplorerChunk::getDisplayedSizeHint(CameraDefinition* camera)
|
||||
float BaseExplorerChunk::getDisplayedSizeHint(CameraDefinition* camera)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
Color BaseExplorerChunk::getTextureColor(double x, double y)
|
||||
Color BaseExplorerChunk::getTextureColor(float x, float y)
|
||||
{
|
||||
return COLOR_TRANSPARENT;
|
||||
}
|
|
@ -15,7 +15,7 @@ public:
|
|||
void updatePriority(CameraDefinition* camera);
|
||||
void render(QGLWidget* widget);
|
||||
|
||||
double priority;
|
||||
float priority;
|
||||
protected:
|
||||
BaseExplorerChunk(Renderer* renderer);
|
||||
|
||||
|
@ -28,8 +28,8 @@ protected:
|
|||
virtual void onResetEvent();
|
||||
virtual bool onMaintainEvent();
|
||||
virtual void onRenderEvent(QGLWidget* widget);
|
||||
virtual double getDisplayedSizeHint(CameraDefinition* camera);
|
||||
virtual Color getTextureColor(double x, double y);
|
||||
virtual float getDisplayedSizeHint(CameraDefinition* camera);
|
||||
virtual Color getTextureColor(float x, float y);
|
||||
|
||||
QMutex _lock_data;
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ void BaseForm::addInputInt(QString label, int* value, int min, int max, int smal
|
|||
addInput(new InputInt(form, label, value, min, max, small_step, large_step));
|
||||
}
|
||||
|
||||
void BaseForm::addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step)
|
||||
void BaseForm::addInputDouble(QString label, float* value, float min, float max, float small_step, float large_step)
|
||||
{
|
||||
addInput(new InputDouble(form, label, value, min, max, small_step, large_step));
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ void BaseForm::addInputNoise(QString label, NoiseGenerator* value)
|
|||
addInput(new InputNoise(form, label, value));
|
||||
}
|
||||
|
||||
void BaseForm::addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax)
|
||||
void BaseForm::addInputCurve(QString label, Curve* value, float xmin, float xmax, float ymin, float ymax)
|
||||
{
|
||||
addInput(new InputCurve(form, label, value, xmin, xmax, ymin, ymax));
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ protected:
|
|||
QPushButton* addButton(QString label);
|
||||
void addInput(BaseInput* input);
|
||||
void addInputInt(QString label, int* value, int min, int max, int small_step, int large_step);
|
||||
void addInputDouble(QString label, double* value, double min, double max, double small_step, double large_step);
|
||||
void addInputDouble(QString label, float* value, float min, float max, float small_step, float large_step);
|
||||
void addInputBoolean(QString label, int* value);
|
||||
void addInputColor(QString label, Color* value);
|
||||
void addInputColorGradation(QString label, ColorGradation* value);
|
||||
void addInputNoise(QString label, NoiseGenerator* value);
|
||||
void addInputCurve(QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
|
||||
void addInputCurve(QString label, Curve* value, float xmin, float xmax, float ymin, float ymax);
|
||||
void addInputMaterial(QString label, SurfaceMaterial* material);
|
||||
|
||||
int currentLayer();
|
||||
|
|
|
@ -318,14 +318,14 @@ void BasePreview::updateData()
|
|||
{
|
||||
}
|
||||
|
||||
QColor BasePreview::getColor(double x, double y)
|
||||
QColor BasePreview::getColor(float x, float y)
|
||||
{
|
||||
return QColor(0, 0, 0);
|
||||
}
|
||||
|
||||
void BasePreview::configScaling(double min, double max, double step, double init, bool logarithmic)
|
||||
void BasePreview::configScaling(float min, float max, float step, float init, bool logarithmic)
|
||||
{
|
||||
double size = (double) width();
|
||||
float size = (float) width();
|
||||
|
||||
if (size >= 1.0)
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ void BasePreview::configScaling(double min, double max, double step, double init
|
|||
}
|
||||
}
|
||||
|
||||
void BasePreview::configScrolling(double xmin, double xmax, double xinit, double ymin, double ymax, double yinit)
|
||||
void BasePreview::configScrolling(float xmin, float xmax, float xinit, float ymin, float ymax, float yinit)
|
||||
{
|
||||
conf_scroll_xmin = xmin;
|
||||
conf_scroll_xmax = xmax;
|
||||
|
@ -388,7 +388,7 @@ void BasePreview::commitChunkTransaction(QImage* chunk, int x, int y, int w, int
|
|||
|
||||
QColor BasePreview::getPixelColor(int x, int y)
|
||||
{
|
||||
return getColor((double) (x - _width / 2) * scaling + xoffset, (double) (y - _height / 2) * scaling + yoffset);
|
||||
return getColor((float) (x - _width / 2) * scaling + xoffset, (float) (y - _height / 2) * scaling + yoffset);
|
||||
}
|
||||
|
||||
void BasePreview::handleRedraw()
|
||||
|
@ -523,8 +523,8 @@ void BasePreview::mouseMoveEvent(QMouseEvent* event)
|
|||
|
||||
if (ndx <= -width || ndx >= width || ndy <= -height || ndy >= height)
|
||||
{
|
||||
xoffset -= (double) ndx * scaling;
|
||||
yoffset -= (double) ndy * scaling;
|
||||
xoffset -= (float) ndx * scaling;
|
||||
yoffset -= (float) ndy * scaling;
|
||||
|
||||
lock_drawing->lock();
|
||||
pixbuf->fill(0x00000000);
|
||||
|
@ -537,8 +537,8 @@ void BasePreview::mouseMoveEvent(QMouseEvent* event)
|
|||
|
||||
lock_drawing->lock();
|
||||
|
||||
xoffset -= (double) ndx * scaling;
|
||||
yoffset -= (double) ndy * scaling;
|
||||
xoffset -= (float) ndx * scaling;
|
||||
yoffset -= (float) ndy * scaling;
|
||||
|
||||
if (ndx < 0)
|
||||
{
|
||||
|
@ -580,8 +580,8 @@ void BasePreview::mouseMoveEvent(QMouseEvent* event)
|
|||
|
||||
void BasePreview::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
double factor;
|
||||
double old_scaling;
|
||||
float factor;
|
||||
float old_scaling;
|
||||
int width, height;
|
||||
int new_width, new_height;
|
||||
|
||||
|
@ -637,8 +637,8 @@ void BasePreview::wheelEvent(QWheelEvent* event)
|
|||
if (scaling < old_scaling)
|
||||
{
|
||||
lock_drawing->lock();
|
||||
new_width = (int) floor(((double) width) * scaling / old_scaling);
|
||||
new_height = (int) floor(((double) height) * scaling / old_scaling);
|
||||
new_width = (int) floor(((float) width) * scaling / old_scaling);
|
||||
new_height = (int) floor(((float) height) * scaling / old_scaling);
|
||||
QImage part = pixbuf->copy((width - new_width) / 2, (height - new_height) / 2, new_width, new_height).scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
pixbuf->fill(0x00000000);
|
||||
QPainter painter(pixbuf);
|
||||
|
@ -651,7 +651,7 @@ void BasePreview::wheelEvent(QWheelEvent* event)
|
|||
else if (scaling > old_scaling)
|
||||
{
|
||||
lock_drawing->lock();
|
||||
QImage part = pixbuf->scaled((int) floor(((double) width) * old_scaling / scaling), (int) floor(((double) height) * old_scaling / scaling), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
QImage part = pixbuf->scaled((int) floor(((float) width) * old_scaling / scaling), (int) floor(((float) height) * old_scaling / scaling), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
pixbuf->fill(0x00000000);
|
||||
QPainter painter(pixbuf);
|
||||
painter.drawImage((width - part.width()) / 2, (height - part.height()) / 2, part);
|
||||
|
|
|
@ -28,14 +28,14 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void updateData();
|
||||
virtual QColor getColor(double x, double y);
|
||||
virtual QColor getColor(float x, float y);
|
||||
|
||||
void configScaling(double min, double max, double step, double init, bool logarithmic = true);
|
||||
void configScrolling(double xmin, double xmax, double xinit, double ymin, double ymax, double yinit);
|
||||
void configScaling(float min, float max, float step, float init, bool logarithmic = true);
|
||||
void configScrolling(float xmin, float xmax, float xinit, float ymin, float ymax, float yinit);
|
||||
|
||||
double xoffset;
|
||||
double yoffset;
|
||||
double scaling;
|
||||
float xoffset;
|
||||
float yoffset;
|
||||
float scaling;
|
||||
|
||||
private:
|
||||
void updateScaling();
|
||||
|
@ -61,21 +61,21 @@ private:
|
|||
int mousex;
|
||||
int mousey;
|
||||
|
||||
double scalingbase;
|
||||
float scalingbase;
|
||||
|
||||
bool alive;
|
||||
|
||||
double conf_scroll_xmin;
|
||||
double conf_scroll_xmax;
|
||||
double conf_scroll_xinit;
|
||||
double conf_scroll_ymin;
|
||||
double conf_scroll_ymax;
|
||||
double conf_scroll_yinit;
|
||||
float conf_scroll_xmin;
|
||||
float conf_scroll_xmax;
|
||||
float conf_scroll_xinit;
|
||||
float conf_scroll_ymin;
|
||||
float conf_scroll_ymax;
|
||||
float conf_scroll_yinit;
|
||||
|
||||
double conf_scale_min;
|
||||
double conf_scale_max;
|
||||
double conf_scale_init;
|
||||
double conf_scale_step;
|
||||
float conf_scale_min;
|
||||
float conf_scale_max;
|
||||
float conf_scale_init;
|
||||
float conf_scale_step;
|
||||
bool conf_scroll_logarithmic;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "widgetcurveeditor.h"
|
||||
|
||||
/**************** Dialog ****************/
|
||||
DialogCurve::DialogCurve(QWidget *parent, Curve* curve, double xmin, double xmax, double ymin, double ymax) : QDialog(parent)
|
||||
DialogCurve::DialogCurve(QWidget *parent, Curve* curve, float xmin, float xmax, float ymin, float ymax) : QDialog(parent)
|
||||
{
|
||||
QWidget* buttons;
|
||||
QWidget* form;
|
||||
|
@ -70,7 +70,7 @@ DialogCurve::~DialogCurve()
|
|||
curveDelete(_current);
|
||||
}
|
||||
|
||||
bool DialogCurve::getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax)
|
||||
bool DialogCurve::getCurve(QWidget* parent, Curve* curve, float xmin, float xmax, float ymin, float ymax)
|
||||
{
|
||||
int result;
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ class DialogCurve : public QDialog
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialogCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax);
|
||||
explicit DialogCurve(QWidget* parent, Curve* curve, float xmin, float xmax, float ymin, float ymax);
|
||||
~DialogCurve();
|
||||
|
||||
static bool getCurve(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax);
|
||||
static bool getCurve(QWidget* parent, Curve* curve, float xmin, float xmax, float ymin, float ymax);
|
||||
|
||||
public slots:
|
||||
virtual void accept();
|
||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
|||
{
|
||||
noiseCopy(_noise_original, _noise_preview);
|
||||
}
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
if ((_level >= 0) && (y > noiseGet1DLevel(_noise_preview, _level, x)))
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ protected:
|
|||
{
|
||||
noiseCopy(_noise_original, _noise_preview);
|
||||
}
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
if (y > noiseGet1DTotal(_noise_preview, x))
|
||||
{
|
||||
|
@ -295,7 +295,7 @@ void DialogNoise::levelChanged(int row)
|
|||
|
||||
void DialogNoise::heightChanged(int value)
|
||||
{
|
||||
_current_level_params.height = ((double)value) / 1000.0;
|
||||
_current_level_params.height = ((float)value) / 1000.0;
|
||||
noiseSetLevel(_current, _current_level, _current_level_params);
|
||||
previewLevel->redraw();
|
||||
previewTotal->redraw();
|
||||
|
@ -303,7 +303,7 @@ void DialogNoise::heightChanged(int value)
|
|||
|
||||
void DialogNoise::scalingChanged(int value)
|
||||
{
|
||||
_current_level_params.scaling = ((double)value) / 1000.0;
|
||||
_current_level_params.scaling = ((float)value) / 1000.0;
|
||||
noiseSetLevel(_current, _current_level, _current_level_params);
|
||||
previewLevel->redraw();
|
||||
previewTotal->redraw();
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#include "dialogrender.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <QVBoxLayout>
|
||||
#include <QImage>
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
#include "tools.h"
|
||||
|
||||
#include "../lib_paysages/scenery.h"
|
||||
|
@ -24,10 +26,10 @@ static void _renderDraw(int x, int y, Color col)
|
|||
_current_dialog->pixbuf->setPixel(x, _current_dialog->pixbuf->height() - 1 - y, colorToQColor(col).rgb());
|
||||
}
|
||||
|
||||
static void _renderUpdate(double progress)
|
||||
static void _renderUpdate(float progress)
|
||||
{
|
||||
_current_dialog->area->update();
|
||||
_current_dialog->progress_value = progress * 1000.0;
|
||||
_current_dialog->tellProgressChange(progress);
|
||||
}
|
||||
|
||||
class RenderThread:public QThread
|
||||
|
@ -60,8 +62,6 @@ public:
|
|||
{
|
||||
QPainter painter(this);
|
||||
painter.drawImage(0, 0, *_current_dialog->pixbuf);
|
||||
_current_dialog->progress->setValue(_current_dialog->progress_value);
|
||||
_current_dialog->progress->update();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -70,40 +70,45 @@ DialogRender::DialogRender(QWidget *parent, Renderer* renderer):
|
|||
{
|
||||
pixbuf = new QImage(1, 1, QImage::Format_ARGB32);
|
||||
_current_dialog = this;
|
||||
render_thread = NULL;
|
||||
_render_thread = NULL;
|
||||
_renderer = renderer;
|
||||
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Paysages 3D - Render"));
|
||||
setLayout(new QVBoxLayout());
|
||||
|
||||
scroll = new QScrollArea(this);
|
||||
scroll->setAlignment(Qt::AlignCenter);
|
||||
area = new RenderArea(scroll);
|
||||
scroll->setWidget(area);
|
||||
layout()->addWidget(scroll);
|
||||
_scroll = new QScrollArea(this);
|
||||
_scroll->setAlignment(Qt::AlignCenter);
|
||||
area = new RenderArea(_scroll);
|
||||
_scroll->setWidget(area);
|
||||
layout()->addWidget(_scroll);
|
||||
|
||||
_info = new QWidget(this);
|
||||
_info->setLayout(new QHBoxLayout());
|
||||
layout()->addWidget(_info);
|
||||
|
||||
progress = new QProgressBar(this);
|
||||
progress->setMinimum(0);
|
||||
progress->setMaximum(1000);
|
||||
progress->setValue(0);
|
||||
layout()->addWidget(progress);
|
||||
progress_value = 0;
|
||||
_timer = new QLabel(QString("0:00.00"), _info);
|
||||
_info->layout()->addWidget(_timer);
|
||||
|
||||
_progress = new QProgressBar(_info);
|
||||
_progress->setMaximumHeight(12);
|
||||
_progress->setMinimum(0);
|
||||
_progress->setMaximum(1000);
|
||||
_progress->setValue(0);
|
||||
_info->layout()->addWidget(_progress);
|
||||
|
||||
connect(this, SIGNAL(renderSizeChanged(int, int)), this, SLOT(applyRenderSize(int, int)));
|
||||
|
||||
// TEMP
|
||||
progress->hide();
|
||||
connect(this, SIGNAL(progressChanged(float)), this, SLOT(applyProgress(float)));
|
||||
}
|
||||
|
||||
DialogRender::~DialogRender()
|
||||
{
|
||||
if (render_thread)
|
||||
if (_render_thread)
|
||||
{
|
||||
rendererInterrupt(_renderer);
|
||||
render_thread->wait();
|
||||
_render_thread->wait();
|
||||
|
||||
delete render_thread;
|
||||
delete _render_thread;
|
||||
}
|
||||
delete pixbuf;
|
||||
}
|
||||
|
@ -113,13 +118,20 @@ void DialogRender::tellRenderSize(int width, int height)
|
|||
emit renderSizeChanged(width, height);
|
||||
}
|
||||
|
||||
void DialogRender::tellProgressChange(float value)
|
||||
{
|
||||
emit progressChanged(value);
|
||||
}
|
||||
|
||||
void DialogRender::startRender(RenderParams params)
|
||||
{
|
||||
_started = time(NULL);
|
||||
|
||||
//applyRenderSize(params.width, params.height);
|
||||
rendererSetPreviewCallbacks(_renderer, _renderStart, _renderDraw, _renderUpdate);
|
||||
|
||||
render_thread = new RenderThread(_renderer, params);
|
||||
render_thread->start();
|
||||
_render_thread = new RenderThread(_renderer, params);
|
||||
_render_thread->start();
|
||||
|
||||
exec();
|
||||
}
|
||||
|
@ -127,7 +139,7 @@ void DialogRender::startRender(RenderParams params)
|
|||
void DialogRender::loadLastRender()
|
||||
{
|
||||
//applyRenderSize(_renderer->render_width, _renderer->render_height);
|
||||
progress->hide();
|
||||
_info->hide();
|
||||
rendererSetPreviewCallbacks(_renderer, _renderStart, _renderDraw, _renderUpdate);
|
||||
|
||||
exec();
|
||||
|
@ -138,5 +150,17 @@ void DialogRender::applyRenderSize(int width, int height)
|
|||
area->setMinimumSize(width, height);
|
||||
area->setMaximumSize(width, height);
|
||||
area->resize(width, height);
|
||||
scroll->setMinimumSize(width > 800 ? 820 : width + 20, height > 600 ? 620 : height + 20);
|
||||
_scroll->setMinimumSize(width > 800 ? 820 : width + 20, height > 600 ? 620 : height + 20);
|
||||
}
|
||||
|
||||
void DialogRender::applyProgress(float value)
|
||||
{
|
||||
double diff = difftime(time(NULL), _started);
|
||||
int hours = (int)floor(diff / 3600.0);
|
||||
int minutes = (int)floor((diff - 3600.0 * hours) / 60.0);
|
||||
int seconds = (int)floor(diff - 3600.0 * hours - 60.0 * minutes);
|
||||
_timer->setText(tr("%1:%2.%3").arg(hours).arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')));
|
||||
_progress->setValue((int)(value * 1000.0));
|
||||
_progress->update();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef _PAYSAGES_QT_DIALOGRENDER_H_
|
||||
#define _PAYSAGES_QT_DIALOGRENDER_H_
|
||||
|
||||
#include <time.h>
|
||||
#include <QDialog>
|
||||
#include <QThread>
|
||||
#include <QProgressBar>
|
||||
#include <QScrollArea>
|
||||
#include <QLabel>
|
||||
#include "../lib_paysages/renderer.h"
|
||||
|
||||
class DialogRender : public QDialog
|
||||
|
@ -15,24 +17,29 @@ public:
|
|||
~DialogRender();
|
||||
|
||||
void tellRenderSize(int width, int height);
|
||||
void tellProgressChange(float value);
|
||||
void startRender(RenderParams params);
|
||||
void loadLastRender();
|
||||
|
||||
QImage* pixbuf;
|
||||
QWidget* area;
|
||||
QProgressBar* progress;
|
||||
int progress_value;
|
||||
|
||||
private slots:
|
||||
void applyRenderSize(int width, int height);
|
||||
void applyProgress(float value);
|
||||
|
||||
signals:
|
||||
void renderSizeChanged(int width, int height);
|
||||
void progressChanged(float value);
|
||||
|
||||
private:
|
||||
QScrollArea* scroll;
|
||||
QThread* render_thread;
|
||||
QScrollArea* _scroll;
|
||||
QWidget* _info;
|
||||
QThread* _render_thread;
|
||||
QLabel* _timer;
|
||||
Renderer* _renderer;
|
||||
QProgressBar* _progress;
|
||||
time_t _started;
|
||||
};
|
||||
|
||||
#endif // _PAYSAGES_QT_DIALOGRENDER_H_
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "baseexplorerchunk.h"
|
||||
#include "../lib_paysages/camera.h"
|
||||
|
||||
ExplorerChunkSky::ExplorerChunkSky(Renderer* renderer, SkyDefinition* sky, double size, SkyboxOrientation orientation) : BaseExplorerChunk(renderer)
|
||||
ExplorerChunkSky::ExplorerChunkSky(Renderer* renderer, SkyDefinition* sky, float size, SkyboxOrientation orientation) : BaseExplorerChunk(renderer)
|
||||
{
|
||||
_sky = sky;
|
||||
_box_size = size;
|
||||
|
@ -16,7 +16,7 @@ ExplorerChunkSky::ExplorerChunkSky(Renderer* renderer, SkyDefinition* sky, doubl
|
|||
|
||||
void ExplorerChunkSky::onRenderEvent(QGLWidget* widget)
|
||||
{
|
||||
double size = _box_size;
|
||||
float size = _box_size;
|
||||
Vector3 camera = renderer()->camera_location;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -86,12 +86,12 @@ void ExplorerChunkSky::onRenderEvent(QGLWidget* widget)
|
|||
glEnd();
|
||||
}
|
||||
|
||||
double ExplorerChunkSky::getDisplayedSizeHint(CameraDefinition* camera)
|
||||
float ExplorerChunkSky::getDisplayedSizeHint(CameraDefinition* camera)
|
||||
{
|
||||
return 1000.0;
|
||||
}
|
||||
|
||||
Color ExplorerChunkSky::getTextureColor(double x, double y)
|
||||
Color ExplorerChunkSky::getTextureColor(float x, float y)
|
||||
{
|
||||
Vector3 location;
|
||||
|
||||
|
|
|
@ -19,16 +19,16 @@ enum SkyboxOrientation
|
|||
class ExplorerChunkSky:public BaseExplorerChunk
|
||||
{
|
||||
public:
|
||||
ExplorerChunkSky(Renderer* renderer, SkyDefinition* sky, double size, SkyboxOrientation orientation);
|
||||
ExplorerChunkSky(Renderer* renderer, SkyDefinition* sky, float size, SkyboxOrientation orientation);
|
||||
|
||||
void onRenderEvent(QGLWidget* widget);
|
||||
double getDisplayedSizeHint(CameraDefinition* camera);
|
||||
Color getTextureColor(double x, double y);
|
||||
float getDisplayedSizeHint(CameraDefinition* camera);
|
||||
Color getTextureColor(float x, float y);
|
||||
|
||||
private:
|
||||
SkyDefinition* _sky;
|
||||
SkyboxOrientation _orientation;
|
||||
double _box_size;
|
||||
float _box_size;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
#include "baseexplorerchunk.h"
|
||||
#include "../lib_paysages/camera.h"
|
||||
|
||||
ExplorerChunkTerrain::ExplorerChunkTerrain(Renderer* renderer, double x, double z, double size, int nbchunks) : BaseExplorerChunk(renderer)
|
||||
ExplorerChunkTerrain::ExplorerChunkTerrain(Renderer* renderer, float x, float z, float size, int nbchunks) : BaseExplorerChunk(renderer)
|
||||
{
|
||||
_startx = x;
|
||||
_startz = z;
|
||||
_size = size;
|
||||
_overall_step = size * (double)nbchunks;
|
||||
_overall_step = size * (float)nbchunks;
|
||||
|
||||
_tessellation_max_size = 32;
|
||||
_tessellation = new double[(_tessellation_max_size + 1) * (_tessellation_max_size + 1)];
|
||||
_tessellation = new float[(_tessellation_max_size + 1) * (_tessellation_max_size + 1)];
|
||||
_tessellation_current_size = 0;
|
||||
_tessellation_step = _size / (double)_tessellation_max_size;
|
||||
_tessellation_step = _size / (float)_tessellation_max_size;
|
||||
|
||||
setMaxTextureSize(128);
|
||||
|
||||
|
@ -49,7 +49,7 @@ bool ExplorerChunkTerrain::onMaintainEvent()
|
|||
{
|
||||
if (_tessellation_current_size == 0 || i % old_tessellation_inc != 0 || j % old_tessellation_inc != 0)
|
||||
{
|
||||
double height = renderer->getTerrainHeight(renderer, _startx + _tessellation_step * (double)i, _startz + _tessellation_step * (double)j);
|
||||
float height = renderer->getTerrainHeight(renderer, _startx + _tessellation_step * (float)i, _startz + _tessellation_step * (float)j);
|
||||
_tessellation[j * (_tessellation_max_size + 1) + i] = height;
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ void ExplorerChunkTerrain::onRenderEvent(QGLWidget* widget)
|
|||
{
|
||||
_lock_data.lock();
|
||||
int tessellation_size = _tessellation_current_size;
|
||||
double tsize = 1.0 / (double)_tessellation_max_size;
|
||||
float tsize = 1.0 / (float)_tessellation_max_size;
|
||||
_lock_data.unlock();
|
||||
|
||||
if (tessellation_size <= 1)
|
||||
|
@ -106,24 +106,24 @@ void ExplorerChunkTerrain::onRenderEvent(QGLWidget* widget)
|
|||
return;
|
||||
}
|
||||
|
||||
int tessellation_inc = _tessellation_max_size / (double)tessellation_size;
|
||||
int tessellation_inc = _tessellation_max_size / (float)tessellation_size;
|
||||
for (int j = 0; j < _tessellation_max_size; j += tessellation_inc)
|
||||
{
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (int i = 0; i <= _tessellation_max_size; i += tessellation_inc)
|
||||
{
|
||||
glTexCoord2d(tsize * (double)i, tsize * (double)j);
|
||||
glVertex3d(_startx + _tessellation_step * (double)i, _tessellation[j * (_tessellation_max_size + 1) + i], _startz + _tessellation_step * (double)j);
|
||||
glTexCoord2d(tsize * (double)i, tsize * (double)(j + tessellation_inc));
|
||||
glVertex3d(_startx + _tessellation_step * (double)i, _tessellation[(j + tessellation_inc) * (_tessellation_max_size + 1) + i], _startz + _tessellation_step * (double)(j + tessellation_inc));
|
||||
glTexCoord2d(tsize * (float)i, tsize * (float)j);
|
||||
glVertex3d(_startx + _tessellation_step * (float)i, _tessellation[j * (_tessellation_max_size + 1) + i], _startz + _tessellation_step * (float)j);
|
||||
glTexCoord2d(tsize * (float)i, tsize * (float)(j + tessellation_inc));
|
||||
glVertex3d(_startx + _tessellation_step * (float)i, _tessellation[(j + tessellation_inc) * (_tessellation_max_size + 1) + i], _startz + _tessellation_step * (float)(j + tessellation_inc));
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
double ExplorerChunkTerrain::getDisplayedSizeHint(CameraDefinition* camera)
|
||||
float ExplorerChunkTerrain::getDisplayedSizeHint(CameraDefinition* camera)
|
||||
{
|
||||
double distance;
|
||||
float distance;
|
||||
Vector3 center;
|
||||
|
||||
center = getCenter();
|
||||
|
@ -140,7 +140,7 @@ double ExplorerChunkTerrain::getDisplayedSizeHint(CameraDefinition* camera)
|
|||
}
|
||||
}
|
||||
|
||||
Color ExplorerChunkTerrain::getTextureColor(double x, double y)
|
||||
Color ExplorerChunkTerrain::getTextureColor(float x, float y)
|
||||
{
|
||||
Vector3 location = {_startx + x * _size, 0.0, _startz + y * _size};
|
||||
return renderer()->applyTextures(renderer(), location, 0.01);
|
||||
|
|
|
@ -8,28 +8,28 @@
|
|||
class ExplorerChunkTerrain:public BaseExplorerChunk
|
||||
{
|
||||
public:
|
||||
ExplorerChunkTerrain(Renderer* renderer, double x, double z, double size, int nbchunks);
|
||||
ExplorerChunkTerrain(Renderer* renderer, float x, float z, float size, int nbchunks);
|
||||
~ExplorerChunkTerrain();
|
||||
|
||||
void onCameraEvent(CameraDefinition* camera);
|
||||
void onResetEvent();
|
||||
bool onMaintainEvent();
|
||||
void onRenderEvent(QGLWidget* widget);
|
||||
double getDisplayedSizeHint(CameraDefinition* camera);
|
||||
Color getTextureColor(double x, double y);
|
||||
float getDisplayedSizeHint(CameraDefinition* camera);
|
||||
Color getTextureColor(float x, float y);
|
||||
|
||||
private:
|
||||
Vector3 getCenter();
|
||||
|
||||
double _startx;
|
||||
double _startz;
|
||||
double _size;
|
||||
double _overall_step;
|
||||
float _startx;
|
||||
float _startz;
|
||||
float _size;
|
||||
float _overall_step;
|
||||
|
||||
double* _tessellation;
|
||||
float* _tessellation;
|
||||
int _tessellation_max_size;
|
||||
int _tessellation_current_size;
|
||||
double _tessellation_step;
|
||||
float _tessellation_step;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
configScaling(100.0, 1000.0, 20.0, 200.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
Vector3 eye, look, location;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
configScaling(100.0, 1000.0, 20.0, 200.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
Vector3 eye, look;
|
||||
Color color_layer, result;
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
configScaling(1.0, 4.0, 0.2, 2.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
Vector3 start, end;
|
||||
Color color_layer, result;
|
||||
|
@ -120,9 +120,9 @@ private:
|
|||
CloudsLayerDefinition _preview_layer;
|
||||
LightingDefinition _lighting;
|
||||
|
||||
static double _coverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
||||
static float _coverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
||||
{
|
||||
double dist = v3Norm(position);
|
||||
float dist = v3Norm(position);
|
||||
|
||||
if (dist >= layer->ymax)
|
||||
{
|
||||
|
|
|
@ -37,11 +37,11 @@ public:
|
|||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
Vector3 down = {0.0, -1.0, 0.0};
|
||||
Vector3 location;
|
||||
double height = terrainGetHeight(&_terrain, x, y);
|
||||
float height = terrainGetHeight(&_terrain, x, y);
|
||||
|
||||
if (height < _water.height)
|
||||
{
|
||||
|
@ -69,12 +69,12 @@ private:
|
|||
TexturesDefinition _textures;
|
||||
LightingDefinition _lighting;
|
||||
|
||||
static double _getTerrainHeight(Renderer* renderer, double x, double z)
|
||||
static float _getTerrainHeight(Renderer* renderer, float x, float z)
|
||||
{
|
||||
return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z);
|
||||
}
|
||||
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, double precision)
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, float precision)
|
||||
{
|
||||
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
configScaling(0.5, 5.0, 0.5, 2.5);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
y -= 100.0 * scaling;
|
||||
if (y > 0.0)
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
configScaling(0.5, 5.0, 0.5, 2.5);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
y -= 100.0 * scaling;
|
||||
if (y > 0.0)
|
||||
|
|
|
@ -23,9 +23,9 @@ public:
|
|||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
double height;
|
||||
float height;
|
||||
|
||||
height = terrainGetHeightNormalized(&_preview_definition, x, y);
|
||||
return QColor((int)(255.0 * height), (int)(255.0 * height), (int)(255.0 * height));
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
return colorToQColor(terrainGetColor(&_terrain, &_renderer, x, y, scaling));
|
||||
}
|
||||
|
@ -115,12 +115,12 @@ private:
|
|||
TexturesDefinition _textures;
|
||||
LightingDefinition _lighting;
|
||||
|
||||
static double _getTerrainHeight(Renderer* renderer, double x, double z)
|
||||
static float _getTerrainHeight(Renderer* renderer, float x, float z)
|
||||
{
|
||||
return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z);
|
||||
}
|
||||
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, double precision)
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, float precision)
|
||||
{
|
||||
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ static TextureLayerDefinition _layer;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double height_soft_min;
|
||||
double height_hard_min;
|
||||
double height_hard_max;
|
||||
double height_soft_max;
|
||||
double slope_soft_min;
|
||||
double slope_hard_min;
|
||||
double slope_hard_max;
|
||||
double slope_soft_max;
|
||||
float height_soft_min;
|
||||
float height_hard_min;
|
||||
float height_hard_max;
|
||||
float height_soft_max;
|
||||
float slope_soft_min;
|
||||
float slope_hard_min;
|
||||
float slope_hard_max;
|
||||
float slope_soft_max;
|
||||
} TextureSupp;
|
||||
static TextureSupp _supp;
|
||||
|
||||
|
@ -39,10 +39,10 @@ public:
|
|||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
Vector3 location;
|
||||
double coverage;
|
||||
float coverage;
|
||||
location.x = x;
|
||||
location.y = terrainGetHeight(&_terrain, x, y);
|
||||
location.z = y;
|
||||
|
@ -56,7 +56,7 @@ protected:
|
|||
}
|
||||
|
||||
private:
|
||||
static double _getTerrainHeight(Renderer* renderer, double x, double z)
|
||||
static float _getTerrainHeight(Renderer* renderer, float x, float z)
|
||||
{
|
||||
return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
Vector3 location;
|
||||
location.x = x;
|
||||
|
|
|
@ -28,9 +28,9 @@ public:
|
|||
configScrolling(-1000.0, 1000.0, 0.0, -1000.0, 1000.0, 0.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
double height;
|
||||
float height;
|
||||
|
||||
height = terrainGetHeight(&_terrain, x, y);
|
||||
if (height > _definition.height)
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
//configScrolling(-30.0, 30.0, 0.0, -20.0, 20.0, 0.0);
|
||||
}
|
||||
protected:
|
||||
QColor getColor(double x, double y)
|
||||
QColor getColor(float x, float y)
|
||||
{
|
||||
Vector3 eye, look, location;
|
||||
|
||||
|
@ -126,7 +126,7 @@ private:
|
|||
static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds)
|
||||
{
|
||||
RayCastingResult result;
|
||||
double x, y;
|
||||
float x, y;
|
||||
|
||||
result.hit = 1;
|
||||
if (direction.z < 0.0001)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class CurveSmallPreview:public QWidget
|
||||
{
|
||||
public:
|
||||
CurveSmallPreview(QWidget* parent, Curve* curve, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
|
||||
CurveSmallPreview(QWidget* parent, Curve* curve, float xmin, float xmax, float ymin, float ymax) : QWidget(parent)
|
||||
{
|
||||
_curve = curve;
|
||||
_xmin = xmin;
|
||||
|
@ -27,29 +27,29 @@ public:
|
|||
QPainter painter(this);
|
||||
int width = this->width();
|
||||
int height = this->height();
|
||||
double position, value, prev_value, next_value;
|
||||
float position, value, prev_value, next_value;
|
||||
|
||||
painter.fillRect(rect(), QColor(255, 255, 255));
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
painter.setPen(QColor(0, 0, 0));
|
||||
position = _xmin + (_xmax - _xmin) * (double)x / (double)(width - 1);
|
||||
position = _xmin + (_xmax - _xmin) * (float)x / (float)(width - 1);
|
||||
value = (curveGetValue(_curve, position) - _ymin) * (_ymax - _ymin);
|
||||
prev_value = curveGetValue(_curve, position - 1.0 / (double)(width - 1));
|
||||
next_value = curveGetValue(_curve, position + 1.0 / (double)(width - 1));
|
||||
prev_value = curveGetValue(_curve, position - 1.0 / (float)(width - 1));
|
||||
next_value = curveGetValue(_curve, position + 1.0 / (float)(width - 1));
|
||||
|
||||
painter.drawLine(x, height - 1 - (int)((value + (prev_value - value) / 2.0) * (double)(height - 1)), x, height - 1 - (int)((value + (next_value - value) / 2.0) * (double)(height - 1)));
|
||||
painter.drawPoint(x, height - 1 - (int)(value * (double)(height - 1)));
|
||||
painter.drawLine(x, height - 1 - (int)((value + (prev_value - value) / 2.0) * (float)(height - 1)), x, height - 1 - (int)((value + (next_value - value) / 2.0) * (float)(height - 1)));
|
||||
painter.drawPoint(x, height - 1 - (int)(value * (float)(height - 1)));
|
||||
}
|
||||
}
|
||||
Curve* _curve;
|
||||
double _xmin;
|
||||
double _xmax;
|
||||
double _ymin;
|
||||
double _ymax;
|
||||
float _xmin;
|
||||
float _xmax;
|
||||
float _ymin;
|
||||
float _ymax;
|
||||
};
|
||||
|
||||
InputCurve::InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax) : BaseInput(form, label)
|
||||
InputCurve::InputCurve(QWidget* form, QString label, Curve* value, float xmin, float xmax, float ymin, float ymax) : BaseInput(form, label)
|
||||
{
|
||||
_value = value;
|
||||
_xmin = xmin;
|
||||
|
|
|
@ -11,7 +11,7 @@ class InputCurve:public BaseInput
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputCurve(QWidget* form, QString label, Curve* value, double xmin, double xmax, double ymin, double ymax);
|
||||
InputCurve(QWidget* form, QString label, Curve* value, float xmin, float xmax, float ymin, float ymax);
|
||||
|
||||
public slots:
|
||||
virtual void updatePreview();
|
||||
|
@ -23,10 +23,10 @@ private slots:
|
|||
|
||||
private:
|
||||
Curve* _value;
|
||||
double _xmin;
|
||||
double _xmax;
|
||||
double _ymin;
|
||||
double _ymax;
|
||||
float _xmin;
|
||||
float _xmax;
|
||||
float _ymin;
|
||||
float _ymax;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <QLabel>
|
||||
#include "math.h"
|
||||
|
||||
InputDouble::InputDouble(QWidget* form, QString label, double* value, double min, double max, double small_step, double large_step):
|
||||
InputDouble::InputDouble(QWidget* form, QString label, float* value, float min, float max, float small_step, float large_step):
|
||||
BaseInput(form, label),
|
||||
value(value), min(min), max(max), small_step(small_step), large_step(large_step)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ void InputDouble::applyValue()
|
|||
}
|
||||
else
|
||||
{
|
||||
*value = min + ((double)ivalue) * small_step;
|
||||
*value = min + ((float)ivalue) * small_step;
|
||||
}
|
||||
if (fabs(*value) < 0.0000001)
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ class InputDouble:public BaseInput
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InputDouble(QWidget* form, QString label, double* value, double min, double max, double small_step, double large_step);
|
||||
InputDouble(QWidget* form, QString label, float* value, float min, float max, float small_step, float large_step);
|
||||
|
||||
public slots:
|
||||
virtual void updatePreview();
|
||||
|
@ -19,11 +19,11 @@ public slots:
|
|||
|
||||
private:
|
||||
QSlider* slider;
|
||||
double* value;
|
||||
double min;
|
||||
double max;
|
||||
double small_step;
|
||||
double large_step;
|
||||
float* value;
|
||||
float min;
|
||||
float max;
|
||||
float small_step;
|
||||
float large_step;
|
||||
};
|
||||
|
||||
#endif // _PAYSAGES_QT_INPUTDOUBLE_H_
|
||||
|
|
|
@ -26,12 +26,12 @@ public:
|
|||
QPainter painter(this);
|
||||
int width = this->width();
|
||||
int height = this->height();
|
||||
double value, factor;
|
||||
float value, factor;
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
factor = ((double)(height / 2)) / noiseGetMaxValue(noise);
|
||||
value = noiseGet1DTotal(noise, ((double)x) / factor) * factor;
|
||||
factor = ((float)(height / 2)) / noiseGetMaxValue(noise);
|
||||
value = noiseGet1DTotal(noise, ((float)x) / factor) * factor;
|
||||
painter.setPen(QColor(255, 255, 255));
|
||||
painter.drawLine(x, 0, x, height / 2 + value);
|
||||
painter.setPen(QColor(0, 0, 0));
|
||||
|
|
|
@ -49,16 +49,16 @@ void PreviewColorGradation::paintEvent(QPaintEvent* event)
|
|||
switch (band)
|
||||
{
|
||||
case COLORGRADATIONBAND_RED:
|
||||
painter.setPen(QColor::fromRgbF(curveGetValue(curve, (double)x / (double)width), 0.0, 0.0));
|
||||
painter.setPen(QColor::fromRgbF(curveGetValue(curve, (float)x / (float)width), 0.0, 0.0));
|
||||
break;
|
||||
case COLORGRADATIONBAND_GREEN:
|
||||
painter.setPen(QColor::fromRgbF(0.0, curveGetValue(curve, (double)x / (double)width), 0.0));
|
||||
painter.setPen(QColor::fromRgbF(0.0, curveGetValue(curve, (float)x / (float)width), 0.0));
|
||||
break;
|
||||
case COLORGRADATIONBAND_BLUE:
|
||||
painter.setPen(QColor::fromRgbF(0.0, 0.0, curveGetValue(curve, (double)x / (double)width)));
|
||||
painter.setPen(QColor::fromRgbF(0.0, 0.0, curveGetValue(curve, (float)x / (float)width)));
|
||||
break;
|
||||
case COLORGRADATIONBAND_FINAL:
|
||||
painter.setPen(colorToQColor(colorGradationGet(gradation, (double)x / (double)width)));
|
||||
painter.setPen(colorToQColor(colorGradationGet(gradation, (float)x / (float)width)));
|
||||
break;
|
||||
}
|
||||
painter.drawLine(x, 0, x, height - 1);
|
||||
|
|
|
@ -39,9 +39,9 @@ SmallMaterialPreview::~SmallMaterialPreview()
|
|||
rendererDelete(&_renderer);
|
||||
}
|
||||
|
||||
QColor SmallMaterialPreview::getColor(double x, double y)
|
||||
QColor SmallMaterialPreview::getColor(float x, float y)
|
||||
{
|
||||
double dist = sqrt(x * x + y * y);
|
||||
float dist = sqrt(x * x + y * y);
|
||||
Vector3 point;
|
||||
Color color;
|
||||
|
||||
|
@ -77,24 +77,24 @@ void SmallMaterialPreview::paintEvent(QPaintEvent* event)
|
|||
QPainter painter(this);
|
||||
int width = this->width();
|
||||
int height = this->height();
|
||||
double factor, dx, dy;
|
||||
float factor, dx, dy;
|
||||
|
||||
if (width > height)
|
||||
{
|
||||
factor = 2.0 / (double)height;
|
||||
factor = 2.0 / (float)height;
|
||||
}
|
||||
else
|
||||
{
|
||||
factor = 2.0 / (double)width;
|
||||
factor = 2.0 / (float)width;
|
||||
}
|
||||
dx = factor * (double)width / 2.0;
|
||||
dy = factor * (double)height / 2.0;
|
||||
dx = factor * (float)width / 2.0;
|
||||
dy = factor * (float)height / 2.0;
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
painter.setPen(getColor((double)x * factor - dx, (double)y * factor - dy));
|
||||
painter.setPen(getColor((float)x * factor - dx, (float)y * factor - dy));
|
||||
painter.drawPoint(x, y);
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ PreviewMaterial::~PreviewMaterial()
|
|||
delete _small;
|
||||
}
|
||||
|
||||
QColor PreviewMaterial::getColor(double x, double y)
|
||||
QColor PreviewMaterial::getColor(float x, float y)
|
||||
{
|
||||
return _small->getColor(x, y);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public:
|
|||
SmallMaterialPreview(QWidget* parent, SurfaceMaterial* material);
|
||||
~SmallMaterialPreview();
|
||||
|
||||
QColor getColor(double x, double y);
|
||||
QColor getColor(float x, float y);
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event);
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
~PreviewMaterial();
|
||||
|
||||
protected:
|
||||
virtual QColor getColor(double x, double y);
|
||||
virtual QColor getColor(float x, float y);
|
||||
|
||||
private:
|
||||
SmallMaterialPreview* _small;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <QMouseEvent>
|
||||
#include "../lib_paysages/tools.h"
|
||||
|
||||
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent, double xmin, double xmax, double ymin, double ymax) : QWidget(parent)
|
||||
WidgetCurveEditor::WidgetCurveEditor(QWidget *parent, float xmin, float xmax, float ymin, float ymax) : QWidget(parent)
|
||||
{
|
||||
_curve = curveCreate();
|
||||
_dragged = -1;
|
||||
|
@ -39,14 +39,14 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
|||
{
|
||||
int i, n;
|
||||
int width, height;
|
||||
double dwidth, dheight;
|
||||
float dwidth, dheight;
|
||||
CurvePoint point;
|
||||
double position, value, prev_value, next_value;
|
||||
float position, value, prev_value, next_value;
|
||||
|
||||
width = this->width();
|
||||
height = this->height();
|
||||
dheight = (double)(height - 1);
|
||||
dwidth = (double)(width - 1);
|
||||
dheight = (float)(height - 1);
|
||||
dwidth = (float)(width - 1);
|
||||
|
||||
QPainter painter(this);
|
||||
painter.fillRect(0, 0, width, height, QColor(255, 255, 255));
|
||||
|
@ -54,7 +54,7 @@ void WidgetCurveEditor::paintEvent(QPaintEvent* event)
|
|||
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
position = ((double)x) / dwidth;
|
||||
position = ((float)x) / dwidth;
|
||||
|
||||
value = curveGetValue(_curve, position);
|
||||
prev_value = curveGetValue(_curve, position - 1.0 / dwidth);
|
||||
|
@ -88,8 +88,8 @@ void WidgetCurveEditor::mouseMoveEvent(QMouseEvent* event)
|
|||
|
||||
if (_dragged >= 0 && (event->buttons() & Qt::LeftButton))
|
||||
{
|
||||
point.position = ((double)event->x()) / (double)(width() - 1);
|
||||
point.value = 1.0 - ((double)event->y()) / (double)(height() - 1);
|
||||
point.position = ((float)event->x()) / (float)(width() - 1);
|
||||
point.value = 1.0 - ((float)event->y()) / (float)(height() - 1);
|
||||
|
||||
point.position = (point.position < 0.0) ? 0.0 : point.position;
|
||||
point.position = (point.position > 1.0) ? 1.0 : point.position;
|
||||
|
@ -138,8 +138,8 @@ void WidgetCurveEditor::mouseDoubleClickEvent(QMouseEvent* event)
|
|||
{
|
||||
if (getPointAt(event->x(), event->y()) < 0)
|
||||
{
|
||||
point.position = ((double)event->x()) / (double)(width() - 1);
|
||||
point.value = 1.0 - ((double)event->y()) / (double)(height() - 1);
|
||||
point.position = ((float)event->x()) / (float)(width() - 1);
|
||||
point.value = 1.0 - ((float)event->y()) / (float)(height() - 1);
|
||||
|
||||
curveAddPoint(_curve, &point);
|
||||
curveValidate(_curve);
|
||||
|
@ -153,10 +153,10 @@ int WidgetCurveEditor::getPointAt(int x, int y)
|
|||
{
|
||||
int n;
|
||||
int nearest;
|
||||
double distance, ndistance;
|
||||
float distance, ndistance;
|
||||
CurvePoint point;
|
||||
double dx = ((double)x) / (double)(width() - 1);
|
||||
double dy = 1.0 - ((double)y) / (double)(height() - 1);
|
||||
float dx = ((float)x) / (float)(width() - 1);
|
||||
float dy = 1.0 - ((float)y) / (float)(height() - 1);
|
||||
|
||||
n = curveGetPointCount(_curve);
|
||||
if (n < 1)
|
||||
|
|
|
@ -10,7 +10,7 @@ class WidgetCurveEditor : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WidgetCurveEditor(QWidget* parent, double xmin, double xmax, double ymin, double ymax);
|
||||
WidgetCurveEditor(QWidget* parent, float xmin, float xmax, float ymin, float ymax);
|
||||
~WidgetCurveEditor();
|
||||
|
||||
void setCurve(Curve* curve);
|
||||
|
|
|
@ -48,12 +48,12 @@ private:
|
|||
|
||||
static QVector<ChunkMaintenanceThread*> _threads;
|
||||
|
||||
static double _getTerrainHeight(Renderer* renderer, double x, double z)
|
||||
static float _getTerrainHeight(Renderer* renderer, float x, float z)
|
||||
{
|
||||
return terrainGetHeight((TerrainDefinition*)(renderer->customData[0]), x, z);
|
||||
}
|
||||
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, double precision)
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, float precision)
|
||||
{
|
||||
return texturesGetColor((TexturesDefinition*)(renderer->customData[1]), renderer, location.x, location.z, precision);
|
||||
}
|
||||
|
@ -103,14 +103,14 @@ WidgetExplorer::WidgetExplorer(QWidget *parent, CameraDefinition* camera):
|
|||
|
||||
// Add terrain
|
||||
int chunks = 20;
|
||||
double size = 200.0;
|
||||
double chunksize = size / (double)chunks;
|
||||
double start = -size / 2.0;
|
||||
float size = 200.0;
|
||||
float chunksize = size / (float)chunks;
|
||||
float start = -size / 2.0;
|
||||
for (int i = 0; i < chunks; i++)
|
||||
{
|
||||
for (int j = 0; j < chunks; j++)
|
||||
{
|
||||
ExplorerChunkTerrain* chunk = new ExplorerChunkTerrain(&_renderer, start + chunksize * (double)i, start + chunksize * (double)j, chunksize, chunks);
|
||||
ExplorerChunkTerrain* chunk = new ExplorerChunkTerrain(&_renderer, start + chunksize * (float)i, start + chunksize * (float)j, chunksize, chunks);
|
||||
_chunks.append(chunk);
|
||||
_updateQueue.append(chunk);
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ void WidgetExplorer::validateCamera()
|
|||
|
||||
void WidgetExplorer::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
double factor;
|
||||
float factor;
|
||||
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
|
@ -290,7 +290,7 @@ void WidgetExplorer::mousePressEvent(QMouseEvent* event)
|
|||
|
||||
void WidgetExplorer::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
double factor;
|
||||
float factor;
|
||||
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
|
@ -308,15 +308,15 @@ void WidgetExplorer::mouseMoveEvent(QMouseEvent* event)
|
|||
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
{
|
||||
cameraRotateYaw(&_current_camera, (double)(event->x() - _last_mouse_x) * factor * 0.1);
|
||||
cameraRotatePitch(&_current_camera, (double)(event->y() - _last_mouse_y) * factor * 0.1);
|
||||
cameraRotateYaw(&_current_camera, (float)(event->x() - _last_mouse_x) * factor * 0.1);
|
||||
cameraRotatePitch(&_current_camera, (float)(event->y() - _last_mouse_y) * factor * 0.1);
|
||||
updateGL();
|
||||
event->accept();
|
||||
}
|
||||
else if (event->buttons() & Qt::RightButton)
|
||||
{
|
||||
cameraStrafeRight(&_current_camera, (double)(_last_mouse_x - event->x()) * factor);
|
||||
cameraStrafeUp(&_current_camera, (double)(event->y() - _last_mouse_y) * factor);
|
||||
cameraStrafeRight(&_current_camera, (float)(_last_mouse_x - event->x()) * factor);
|
||||
cameraStrafeUp(&_current_camera, (float)(event->y() - _last_mouse_y) * factor);
|
||||
updateGL();
|
||||
event->accept();
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ void WidgetExplorer::mouseMoveEvent(QMouseEvent* event)
|
|||
|
||||
void WidgetExplorer::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
double factor;
|
||||
float factor;
|
||||
|
||||
if (event->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
|
@ -349,7 +349,7 @@ void WidgetExplorer::wheelEvent(QWheelEvent* event)
|
|||
|
||||
if (event->orientation() == Qt::Vertical)
|
||||
{
|
||||
cameraStrafeForward(&_current_camera, (double)event->delta() * factor);
|
||||
cameraStrafeForward(&_current_camera, (float)event->delta() * factor);
|
||||
updateGL();
|
||||
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ void WidgetExplorer::paintGL()
|
|||
{
|
||||
GLenum error_code;
|
||||
QTime start_time;
|
||||
double frame_time;
|
||||
float frame_time;
|
||||
|
||||
if (_current_camera.location.y > 30.0)
|
||||
{
|
||||
|
@ -452,7 +452,7 @@ void WidgetExplorer::paintGL()
|
|||
_chunks[i]->render(this);
|
||||
}
|
||||
|
||||
frame_time = 0.001 * (double)start_time.msecsTo(QTime::currentTime());
|
||||
frame_time = 0.001 * (float)start_time.msecsTo(QTime::currentTime());
|
||||
|
||||
_average_frame_time = _average_frame_time * 0.8 + frame_time * 0.2;
|
||||
//printf("%d %f\n", quality, average_frame_time);
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
TexturesDefinition _textures;
|
||||
LightingDefinition _lighting;
|
||||
|
||||
double _average_frame_time;
|
||||
float _average_frame_time;
|
||||
int _quality;
|
||||
|
||||
int _last_mouse_x;
|
||||
|
|
|
@ -254,6 +254,11 @@ Maintenir Ctrl : Plus lent</translation>
|
|||
<source>Paysages 3D - Render</source>
|
||||
<translation>Paysages 3D - Rendu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui_qt/dialogrender.cpp" line="162"/>
|
||||
<source>%1:%2.%3</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>DialogWanderer</name>
|
||||
|
|
|
@ -15,18 +15,18 @@ void atmosphereQuit()
|
|||
|
||||
void atmosphereSave(PackStream* stream, AtmosphereDefinition* definition)
|
||||
{
|
||||
packWriteDouble(stream, &definition->distance_near);
|
||||
packWriteDouble(stream, &definition->distance_far);
|
||||
packWriteDouble(stream, &definition->full_mask);
|
||||
packWriteFloat(stream, &definition->distance_near);
|
||||
packWriteFloat(stream, &definition->distance_far);
|
||||
packWriteFloat(stream, &definition->full_mask);
|
||||
packWriteInt(stream, &definition->auto_lock_on_haze);
|
||||
colorSave(stream, &definition->color);
|
||||
}
|
||||
|
||||
void atmosphereLoad(PackStream* stream, AtmosphereDefinition* definition)
|
||||
{
|
||||
packReadDouble(stream, &definition->distance_near);
|
||||
packReadDouble(stream, &definition->distance_far);
|
||||
packReadDouble(stream, &definition->full_mask);
|
||||
packReadFloat(stream, &definition->distance_near);
|
||||
packReadFloat(stream, &definition->distance_far);
|
||||
packReadFloat(stream, &definition->full_mask);
|
||||
packReadInt(stream, &definition->auto_lock_on_haze);
|
||||
colorLoad(stream, &definition->color);
|
||||
|
||||
|
@ -85,8 +85,8 @@ void atmosphereValidateDefinition(AtmosphereDefinition* definition)
|
|||
Color atmosphereApply(AtmosphereDefinition* definition, Renderer* renderer, Vector3 location, Color base)
|
||||
{
|
||||
Color mask = definition->color;
|
||||
double distance = v3Norm(v3Sub(renderer->camera_location, location));
|
||||
double value;
|
||||
float distance = v3Norm(v3Sub(renderer->camera_location, location));
|
||||
float value;
|
||||
|
||||
if (distance < definition->distance_near)
|
||||
{
|
||||
|
|
|
@ -12,9 +12,9 @@ extern "C" {
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double distance_near;
|
||||
double distance_far;
|
||||
double full_mask;
|
||||
float distance_near;
|
||||
float distance_far;
|
||||
float full_mask;
|
||||
int auto_lock_on_haze;
|
||||
Color color;
|
||||
} AtmosphereDefinition;
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
void autoSetDaytime(int hour, int minute)
|
||||
{
|
||||
autoSetDaytimeFraction((double)hour / 24.0 + (double)minute / 1440.0);
|
||||
autoSetDaytimeFraction((float)hour / 24.0 + (float)minute / 1440.0);
|
||||
}
|
||||
|
||||
void autoSetDaytimeFraction(double daytime)
|
||||
void autoSetDaytimeFraction(float daytime)
|
||||
{
|
||||
SkyDefinition sky;
|
||||
/*ColorGradation grad_sun;
|
||||
|
|
|
@ -8,7 +8,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
void autoSetDaytime(int hour, int minute);
|
||||
void autoSetDaytimeFraction(double daytime);
|
||||
void autoSetDaytimeFraction(float daytime);
|
||||
void autoGenRealisticLandscape(int seed);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -20,17 +20,17 @@ void cameraQuit()
|
|||
void cameraSave(PackStream* stream, CameraDefinition* camera)
|
||||
{
|
||||
v3Save(stream, &camera->location);
|
||||
packWriteDouble(stream, &camera->yaw);
|
||||
packWriteDouble(stream, &camera->pitch);
|
||||
packWriteDouble(stream, &camera->roll);
|
||||
packWriteFloat(stream, &camera->yaw);
|
||||
packWriteFloat(stream, &camera->pitch);
|
||||
packWriteFloat(stream, &camera->roll);
|
||||
}
|
||||
|
||||
void cameraLoad(PackStream* stream, CameraDefinition* camera)
|
||||
{
|
||||
v3Load(stream, &camera->location);
|
||||
packReadDouble(stream, &camera->yaw);
|
||||
packReadDouble(stream, &camera->pitch);
|
||||
packReadDouble(stream, &camera->roll);
|
||||
packReadFloat(stream, &camera->yaw);
|
||||
packReadFloat(stream, &camera->pitch);
|
||||
packReadFloat(stream, &camera->roll);
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ void cameraValidateDefinition(CameraDefinition* definition, int check_above)
|
|||
{
|
||||
WaterDefinition water;
|
||||
TerrainDefinition terrain;
|
||||
double water_height, terrain_height, diff;
|
||||
float water_height, terrain_height, diff;
|
||||
Vector3 move;
|
||||
Matrix4 rotation;
|
||||
|
||||
|
@ -128,7 +128,7 @@ void cameraValidateDefinition(CameraDefinition* definition, int check_above)
|
|||
definition->unproject = m4Inverse(definition->project);
|
||||
}
|
||||
|
||||
void cameraSetLocation(CameraDefinition* camera, double x, double y, double z)
|
||||
void cameraSetLocation(CameraDefinition* camera, float x, float y, float z)
|
||||
{
|
||||
camera->location.x = x;
|
||||
camera->location.y = y;
|
||||
|
@ -137,7 +137,7 @@ void cameraSetLocation(CameraDefinition* camera, double x, double y, double z)
|
|||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraSetTarget(CameraDefinition* camera, double x, double y, double z)
|
||||
void cameraSetTarget(CameraDefinition* camera, float x, float y, float z)
|
||||
{
|
||||
Vector3 forward, target;
|
||||
|
||||
|
@ -172,49 +172,49 @@ void cameraSetTarget(CameraDefinition* camera, double x, double y, double z)
|
|||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraSetRoll(CameraDefinition* camera, double angle)
|
||||
void cameraSetRoll(CameraDefinition* camera, float angle)
|
||||
{
|
||||
camera->roll = angle;
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraStrafeForward(CameraDefinition* camera, double value)
|
||||
void cameraStrafeForward(CameraDefinition* camera, float value)
|
||||
{
|
||||
camera->location = v3Add(camera->location, v3Scale(camera->forward, value));
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraStrafeRight(CameraDefinition* camera, double value)
|
||||
void cameraStrafeRight(CameraDefinition* camera, float value)
|
||||
{
|
||||
camera->location = v3Add(camera->location, v3Scale(camera->right, value));
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraStrafeUp(CameraDefinition* camera, double value)
|
||||
void cameraStrafeUp(CameraDefinition* camera, float value)
|
||||
{
|
||||
camera->location = v3Add(camera->location, v3Scale(camera->up, value));
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraRotateYaw(CameraDefinition* camera, double value)
|
||||
void cameraRotateYaw(CameraDefinition* camera, float value)
|
||||
{
|
||||
camera->yaw += value;
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraRotatePitch(CameraDefinition* camera, double value)
|
||||
void cameraRotatePitch(CameraDefinition* camera, float value)
|
||||
{
|
||||
camera->pitch += value;
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
}
|
||||
|
||||
void cameraRotateRoll(CameraDefinition* camera, double value)
|
||||
void cameraRotateRoll(CameraDefinition* camera, float value)
|
||||
{
|
||||
camera->roll += value;
|
||||
|
||||
|
@ -223,8 +223,8 @@ void cameraRotateRoll(CameraDefinition* camera, double value)
|
|||
|
||||
void cameraSetRenderSize(CameraDefinition* camera, int width, int height)
|
||||
{
|
||||
camera->width = (double)width;
|
||||
camera->height = (double)height;
|
||||
camera->width = (float)width;
|
||||
camera->height = (float)height;
|
||||
camera->xratio = camera->width / camera->height;
|
||||
|
||||
cameraValidateDefinition(camera, 0);
|
||||
|
@ -250,7 +250,7 @@ Vector3 cameraUnproject(CameraDefinition* camera, Renderer* renderer, Vector3 po
|
|||
return m4Transform(camera->unproject, point);
|
||||
}
|
||||
|
||||
void cameraProjectToFragment(CameraDefinition* camera, Renderer* renderer, double x, double y, double z, RenderFragment* result)
|
||||
void cameraProjectToFragment(CameraDefinition* camera, Renderer* renderer, float x, float y, float z, RenderFragment* result)
|
||||
{
|
||||
Vector3 point = {x, y, z};
|
||||
point = cameraProject(camera, renderer, point);
|
||||
|
@ -279,20 +279,20 @@ void cameraProjectToFragment(CameraDefinition* camera, Renderer* renderer, doubl
|
|||
v1.callback = callback;
|
||||
|
||||
v.x = 0.0;
|
||||
v.y = (double)render_height;
|
||||
v.y = (float)render_height;
|
||||
v.z = 10.0;
|
||||
v2.location = cameraUnproject(camera, v);
|
||||
v2.color = col;
|
||||
v2.callback = callback;
|
||||
|
||||
v.x = (double)render_width;
|
||||
v.y = (double)render_height;
|
||||
v.x = (float)render_width;
|
||||
v.y = (float)render_height;
|
||||
v.z = 10.0;
|
||||
v3.location = cameraUnproject(camera, v);
|
||||
v3.color = col;
|
||||
v3.callback = callback;
|
||||
|
||||
v.x = (double)render_width;
|
||||
v.x = (float)render_width;
|
||||
v.y = 0.0;
|
||||
v.z = 10.0;
|
||||
v4.location = cameraUnproject(camera, v);
|
||||
|
@ -302,7 +302,7 @@ void cameraProjectToFragment(CameraDefinition* camera, Renderer* renderer, doubl
|
|||
renderPushQuad(&v1, &v2, &v3, &v4);
|
||||
}*/
|
||||
|
||||
static inline void _updateBox(Vector3* point, double* xmin, double* xmax, double* ymin, double* ymax, double* zmax)
|
||||
static inline void _updateBox(Vector3* point, float* xmin, float* xmax, float* ymin, float* ymax, float* zmax)
|
||||
{
|
||||
*xmin = MIN(*xmin, point->x);
|
||||
*xmax = MAX(*xmax, point->x);
|
||||
|
@ -311,10 +311,10 @@ static inline void _updateBox(Vector3* point, double* xmin, double* xmax, double
|
|||
*zmax = MAX(*zmax, point->z);
|
||||
}
|
||||
|
||||
int cameraIsBoxInView(CameraDefinition* camera, Vector3 center, double xsize, double ysize, double zsize)
|
||||
int cameraIsBoxInView(CameraDefinition* camera, Vector3 center, float xsize, float ysize, float zsize)
|
||||
{
|
||||
Vector3 projected;
|
||||
double xmin, xmax, ymin, ymax, zmax;
|
||||
float xmin, xmax, ymin, ymax, zmax;
|
||||
|
||||
center.x -= xsize / 2.0;
|
||||
center.y -= ysize / 2.0;
|
||||
|
|
|
@ -19,24 +19,24 @@ void cameraDeleteDefinition(CameraDefinition* definition);
|
|||
void cameraCopyDefinition(CameraDefinition* source, CameraDefinition* destination);
|
||||
void cameraValidateDefinition(CameraDefinition* definition, int check_above);
|
||||
|
||||
void cameraSetLocation(CameraDefinition* camera, double x, double y, double z);
|
||||
void cameraSetTarget(CameraDefinition* camera, double x, double y, double z);
|
||||
void cameraSetRoll(CameraDefinition* camera, double angle);
|
||||
void cameraSetLocation(CameraDefinition* camera, float x, float y, float z);
|
||||
void cameraSetTarget(CameraDefinition* camera, float x, float y, float z);
|
||||
void cameraSetRoll(CameraDefinition* camera, float angle);
|
||||
|
||||
void cameraStrafeForward(CameraDefinition* camera, double value);
|
||||
void cameraStrafeRight(CameraDefinition* camera, double value);
|
||||
void cameraStrafeUp(CameraDefinition* camera, double value);
|
||||
void cameraRotateYaw(CameraDefinition* camera, double value);
|
||||
void cameraRotatePitch(CameraDefinition* camera, double value);
|
||||
void cameraRotateRoll(CameraDefinition* camera, double value);
|
||||
void cameraStrafeForward(CameraDefinition* camera, float value);
|
||||
void cameraStrafeRight(CameraDefinition* camera, float value);
|
||||
void cameraStrafeUp(CameraDefinition* camera, float value);
|
||||
void cameraRotateYaw(CameraDefinition* camera, float value);
|
||||
void cameraRotatePitch(CameraDefinition* camera, float value);
|
||||
void cameraRotateRoll(CameraDefinition* camera, float value);
|
||||
|
||||
void cameraSetRenderSize(CameraDefinition* camera, int width, int height);
|
||||
|
||||
Vector3 cameraProject(CameraDefinition* camera, Renderer* renderer, Vector3 point);
|
||||
Vector3 cameraUnproject(CameraDefinition* camera, Renderer* renderer, Vector3 point);
|
||||
void cameraProjectToFragment(CameraDefinition* camera, Renderer* renderer, double x, double y, double z, RenderFragment* result);
|
||||
void cameraProjectToFragment(CameraDefinition* camera, Renderer* renderer, float x, float y, float z, RenderFragment* result);
|
||||
/*void cameraPushOverlay(CameraDefinition* camera, Color col, f_RenderFragmentCallback callback);*/
|
||||
int cameraIsBoxInView(CameraDefinition* camera, Vector3 center, double xsize, double ysize, double zsize);
|
||||
int cameraIsBoxInView(CameraDefinition* camera, Vector3 center, float xsize, float ysize, float zsize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ typedef struct
|
|||
{
|
||||
Vector3 start;
|
||||
Vector3 end;
|
||||
double length;
|
||||
float length;
|
||||
} CloudSegment;
|
||||
|
||||
static CloudsLayerDefinition NULL_LAYER;
|
||||
|
@ -39,20 +39,20 @@ void cloudsSave(PackStream* stream, CloudsDefinition* definition)
|
|||
{
|
||||
layer = definition->layers + i;
|
||||
|
||||
packWriteDouble(stream, &layer->ymin);
|
||||
packWriteDouble(stream, &layer->ymax);
|
||||
packWriteFloat(stream, &layer->ymin);
|
||||
packWriteFloat(stream, &layer->ymax);
|
||||
curveSave(stream, layer->coverage_by_altitude);
|
||||
noiseSaveGenerator(stream, layer->shape_noise);
|
||||
noiseSaveGenerator(stream, layer->edge_noise);
|
||||
materialSave(stream, &layer->material);
|
||||
packWriteDouble(stream, &layer->hardness);
|
||||
packWriteDouble(stream, &layer->transparencydepth);
|
||||
packWriteDouble(stream, &layer->lighttraversal);
|
||||
packWriteDouble(stream, &layer->minimumlight);
|
||||
packWriteDouble(stream, &layer->shape_scaling);
|
||||
packWriteDouble(stream, &layer->edge_scaling);
|
||||
packWriteDouble(stream, &layer->edge_length);
|
||||
packWriteDouble(stream, &layer->base_coverage);
|
||||
packWriteFloat(stream, &layer->hardness);
|
||||
packWriteFloat(stream, &layer->transparencydepth);
|
||||
packWriteFloat(stream, &layer->lighttraversal);
|
||||
packWriteFloat(stream, &layer->minimumlight);
|
||||
packWriteFloat(stream, &layer->shape_scaling);
|
||||
packWriteFloat(stream, &layer->edge_scaling);
|
||||
packWriteFloat(stream, &layer->edge_length);
|
||||
packWriteFloat(stream, &layer->base_coverage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,20 +71,20 @@ void cloudsLoad(PackStream* stream, CloudsDefinition* definition)
|
|||
{
|
||||
layer = definition->layers + cloudsAddLayer(definition);
|
||||
|
||||
packReadDouble(stream, &layer->ymin);
|
||||
packReadDouble(stream, &layer->ymax);
|
||||
packReadFloat(stream, &layer->ymin);
|
||||
packReadFloat(stream, &layer->ymax);
|
||||
curveLoad(stream, layer->coverage_by_altitude);
|
||||
noiseLoadGenerator(stream, layer->shape_noise);
|
||||
noiseLoadGenerator(stream, layer->edge_noise);
|
||||
materialLoad(stream, &layer->material);
|
||||
packReadDouble(stream, &layer->hardness);
|
||||
packReadDouble(stream, &layer->transparencydepth);
|
||||
packReadDouble(stream, &layer->lighttraversal);
|
||||
packReadDouble(stream, &layer->minimumlight);
|
||||
packReadDouble(stream, &layer->shape_scaling);
|
||||
packReadDouble(stream, &layer->edge_scaling);
|
||||
packReadDouble(stream, &layer->edge_length);
|
||||
packReadDouble(stream, &layer->base_coverage);
|
||||
packReadFloat(stream, &layer->hardness);
|
||||
packReadFloat(stream, &layer->transparencydepth);
|
||||
packReadFloat(stream, &layer->lighttraversal);
|
||||
packReadFloat(stream, &layer->minimumlight);
|
||||
packReadFloat(stream, &layer->shape_scaling);
|
||||
packReadFloat(stream, &layer->edge_scaling);
|
||||
packReadFloat(stream, &layer->edge_length);
|
||||
packReadFloat(stream, &layer->base_coverage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ void cloudsValidateDefinition(CloudsDefinition* definition)
|
|||
}
|
||||
}
|
||||
|
||||
static double _standardCoverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
||||
static float _standardCoverageFunc(CloudsLayerDefinition* layer, Vector3 position)
|
||||
{
|
||||
if (position.y > layer->ymax || position.y < layer->ymin)
|
||||
{
|
||||
|
@ -269,9 +269,9 @@ void cloudsDeleteLayer(CloudsDefinition* definition, int layer)
|
|||
}
|
||||
}
|
||||
|
||||
static inline double _getDistanceToBorder(CloudsLayerDefinition* layer, Vector3 position)
|
||||
static inline float _getDistanceToBorder(CloudsLayerDefinition* layer, Vector3 position)
|
||||
{
|
||||
double density, coverage, val;
|
||||
float density, coverage, val;
|
||||
|
||||
val = noiseGet3DTotal(layer->shape_noise, position.x / layer->shape_scaling, position.y / layer->shape_scaling, position.z / layer->shape_scaling) / noiseGetMaxValue(layer->shape_noise);
|
||||
coverage = layer->_custom_coverage(layer, position);
|
||||
|
@ -302,11 +302,11 @@ static inline double _getDistanceToBorder(CloudsLayerDefinition* layer, Vector3
|
|||
}
|
||||
}
|
||||
|
||||
static inline Vector3 _getNormal(CloudsLayerDefinition* layer, Vector3 position, double detail)
|
||||
static inline Vector3 _getNormal(CloudsLayerDefinition* layer, Vector3 position, float detail)
|
||||
{
|
||||
Vector3 result = {0.0, 0.0, 0.0};
|
||||
Vector3 dposition;
|
||||
double val, dval;
|
||||
float val, dval;
|
||||
|
||||
val = _getDistanceToBorder(layer, position);
|
||||
|
||||
|
@ -418,21 +418,21 @@ static int _optimizeSearchLimits(CloudsLayerDefinition* layer, Vector3* start, V
|
|||
* @param out_segments Allocated space to fill found segments
|
||||
* @return Number of segments found
|
||||
*/
|
||||
static int _findSegments(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 start, Vector3 direction, double detail, int max_segments, double max_inside_length, double max_total_length, double* inside_length, double* total_length, CloudSegment* out_segments)
|
||||
static int _findSegments(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 start, Vector3 direction, float detail, int max_segments, float max_inside_length, float max_total_length, float* inside_length, float* total_length, CloudSegment* out_segments)
|
||||
{
|
||||
int inside, segment_count;
|
||||
double current_total_length, current_inside_length;
|
||||
double step_length, segment_length, remaining_length;
|
||||
double noise_distance, last_noise_distance;
|
||||
float current_total_length, current_inside_length;
|
||||
float step_length, segment_length, remaining_length;
|
||||
float noise_distance, last_noise_distance;
|
||||
Vector3 walker, step, segment_start;
|
||||
double render_precision;
|
||||
float render_precision;
|
||||
|
||||
if (max_segments <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
render_precision = 15.2 - 1.5 * (double)renderer->render_quality;
|
||||
render_precision = 15.2 - 1.5 * (float)renderer->render_quality;
|
||||
render_precision = render_precision * definition->shape_scaling / 50.0;
|
||||
if (render_precision > max_total_length / 10.0)
|
||||
{
|
||||
|
@ -513,7 +513,7 @@ static int _findSegments(CloudsLayerDefinition* definition, Renderer* renderer,
|
|||
return segment_count;
|
||||
}
|
||||
|
||||
static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 position, double detail)
|
||||
static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 position, float detail)
|
||||
{
|
||||
Vector3 normal;
|
||||
Color col1, col2;
|
||||
|
@ -546,7 +546,7 @@ static Color _applyLayerLighting(CloudsLayerDefinition* definition, Renderer* re
|
|||
Color cloudsGetLayerColor(CloudsLayerDefinition* definition, Renderer* renderer, Vector3 start, Vector3 end)
|
||||
{
|
||||
int i, segment_count;
|
||||
double max_length, detail, total_length, inside_length;
|
||||
float max_length, detail, total_length, inside_length;
|
||||
Vector3 direction;
|
||||
Color result, col;
|
||||
CloudSegment segments[20];
|
||||
|
@ -613,7 +613,7 @@ Color cloudsGetColor(CloudsDefinition* definition, Renderer* renderer, Vector3 s
|
|||
|
||||
Color cloudsLayerFilterLight(CloudsLayerDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light)
|
||||
{
|
||||
double inside_depth, total_depth, factor;
|
||||
float inside_depth, total_depth, factor;
|
||||
CloudSegment segments[20];
|
||||
|
||||
_optimizeSearchLimits(definition, &location, &light_location);
|
||||
|
|
|
@ -14,24 +14,24 @@ extern "C" {
|
|||
|
||||
typedef struct CloudsLayerDefinition CloudsLayerDefinition;
|
||||
|
||||
typedef double (*CloudCoverageFunc)(CloudsLayerDefinition* definition, Vector3 position);
|
||||
typedef float (*CloudCoverageFunc)(CloudsLayerDefinition* definition, Vector3 position);
|
||||
|
||||
struct CloudsLayerDefinition
|
||||
{
|
||||
double ymin;
|
||||
double ymax;
|
||||
double base_coverage;
|
||||
float ymin;
|
||||
float ymax;
|
||||
float base_coverage;
|
||||
Curve* coverage_by_altitude;
|
||||
NoiseGenerator* shape_noise;
|
||||
double shape_scaling;
|
||||
float shape_scaling;
|
||||
NoiseGenerator* edge_noise;
|
||||
double edge_scaling;
|
||||
double edge_length;
|
||||
float edge_scaling;
|
||||
float edge_length;
|
||||
SurfaceMaterial material;
|
||||
double hardness;
|
||||
double transparencydepth;
|
||||
double lighttraversal;
|
||||
double minimumlight;
|
||||
float hardness;
|
||||
float transparencydepth;
|
||||
float lighttraversal;
|
||||
float minimumlight;
|
||||
CloudCoverageFunc _custom_coverage;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,18 +23,18 @@ struct ColorGradation
|
|||
|
||||
void colorSave(PackStream* stream, Color* col)
|
||||
{
|
||||
packWriteDouble(stream, &col->r);
|
||||
packWriteDouble(stream, &col->g);
|
||||
packWriteDouble(stream, &col->b);
|
||||
packWriteDouble(stream, &col->a);
|
||||
packWriteFloat(stream, &col->r);
|
||||
packWriteFloat(stream, &col->g);
|
||||
packWriteFloat(stream, &col->b);
|
||||
packWriteFloat(stream, &col->a);
|
||||
}
|
||||
|
||||
void colorLoad(PackStream* stream, Color* col)
|
||||
{
|
||||
packReadDouble(stream, &col->r);
|
||||
packReadDouble(stream, &col->g);
|
||||
packReadDouble(stream, &col->b);
|
||||
packReadDouble(stream, &col->a);
|
||||
packReadFloat(stream, &col->r);
|
||||
packReadFloat(stream, &col->g);
|
||||
packReadFloat(stream, &col->b);
|
||||
packReadFloat(stream, &col->a);
|
||||
}
|
||||
|
||||
unsigned int colorTo32BitRGBA(Color* col)
|
||||
|
@ -59,15 +59,15 @@ unsigned int colorTo32BitABGR(Color* col)
|
|||
|
||||
void colorMask(Color* base, Color* mask)
|
||||
{
|
||||
double new_a;
|
||||
float new_a;
|
||||
new_a = base->a + mask->a - (base->a * mask->a);
|
||||
base->r = (mask->r * mask->a + base->r * base->a - base->r * base->a * mask->a) / new_a;
|
||||
base->g = (mask->g * mask->a + base->g * base->a - base->g * base->a * mask->a) / new_a;
|
||||
base->b = (mask->b * mask->a + base->b * base->a - base->b * base->a * mask->a) / new_a;
|
||||
base->a = new_a;
|
||||
|
||||
/*double mask_weight = mask->a;
|
||||
double base_weight = 1.0 - mask_weight;
|
||||
/*float mask_weight = mask->a;
|
||||
float 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;
|
||||
|
@ -75,9 +75,9 @@ void colorMask(Color* base, Color* mask)
|
|||
base->a = base->a + mask_weight * (1.0 - base->a);*/
|
||||
}
|
||||
|
||||
double colorNormalize(Color* col)
|
||||
float colorNormalize(Color* col)
|
||||
{
|
||||
double max = colorGetValue(col);
|
||||
float max = colorGetValue(col);
|
||||
|
||||
assert(col->r >= 0.0);
|
||||
assert(col->g >= 0.0);
|
||||
|
@ -93,9 +93,9 @@ double colorNormalize(Color* col)
|
|||
return max;
|
||||
}
|
||||
|
||||
double colorGetValue(Color* col)
|
||||
float colorGetValue(Color* col)
|
||||
{
|
||||
double max;
|
||||
float max;
|
||||
|
||||
max = col->r;
|
||||
if (col->g > max)
|
||||
|
@ -183,12 +183,12 @@ void colorGradationSetBlueCurve(ColorGradation* gradation, Curve* curve)
|
|||
curveValidate(gradation->blue);
|
||||
}
|
||||
|
||||
void colorGradationQuickAdd(ColorGradation* gradation, double value, Color* col)
|
||||
void colorGradationQuickAdd(ColorGradation* gradation, float value, Color* col)
|
||||
{
|
||||
colorGradationQuickAddRgb(gradation, value, col->r, col->g, col->b);
|
||||
}
|
||||
|
||||
void colorGradationQuickAddRgb(ColorGradation* gradation, double value, double r, double g, double b)
|
||||
void colorGradationQuickAddRgb(ColorGradation* gradation, float value, float r, float g, float b)
|
||||
{
|
||||
curveQuickAddPoint(gradation->red, value, r);
|
||||
curveValidate(gradation->red);
|
||||
|
@ -200,7 +200,7 @@ void colorGradationQuickAddRgb(ColorGradation* gradation, double value, double r
|
|||
curveValidate(gradation->blue);
|
||||
}
|
||||
|
||||
Color colorGradationGet(ColorGradation* gradation, double value)
|
||||
Color colorGradationGet(ColorGradation* gradation, float value)
|
||||
{
|
||||
Color result;
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ extern "C" {
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double r;
|
||||
double g;
|
||||
double b;
|
||||
double a;
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float a;
|
||||
} Color;
|
||||
|
||||
extern Color COLOR_TRANSPARENT;
|
||||
|
@ -33,8 +33,8 @@ unsigned int colorTo32BitARGB(Color* col);
|
|||
unsigned int colorTo32BitABGR(Color* col);
|
||||
|
||||
void colorMask(Color* base, Color* mask);
|
||||
double colorNormalize(Color* col);
|
||||
double colorGetValue(Color* col);
|
||||
float colorNormalize(Color* col);
|
||||
float colorGetValue(Color* col);
|
||||
|
||||
/* ColorGradation */
|
||||
typedef struct ColorGradation ColorGradation;
|
||||
|
@ -54,10 +54,10 @@ void colorGradationSetRedCurve(ColorGradation* gradation, Curve* curve);
|
|||
void colorGradationSetGreenCurve(ColorGradation* gradation, Curve* curve);
|
||||
void colorGradationSetBlueCurve(ColorGradation* gradation, Curve* curve);
|
||||
|
||||
void colorGradationQuickAdd(ColorGradation* gradation, double value, Color* col);
|
||||
void colorGradationQuickAddRgb(ColorGradation* gradation, double value, double r, double g, double b);
|
||||
void colorGradationQuickAdd(ColorGradation* gradation, float value, Color* col);
|
||||
void colorGradationQuickAddRgb(ColorGradation* gradation, float value, float r, float g, float b);
|
||||
|
||||
Color colorGradationGet(ColorGradation* gradation, double value);
|
||||
Color colorGradationGet(ColorGradation* gradation, float value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ void curveSave(PackStream* stream, Curve* curve)
|
|||
packWriteInt(stream, &curve->nbpoints);
|
||||
for (i = 0; i < curve->nbpoints; i++)
|
||||
{
|
||||
packWriteDouble(stream, &curve->points[i].position);
|
||||
packWriteDouble(stream, &curve->points[i].value);
|
||||
packWriteFloat(stream, &curve->points[i].position);
|
||||
packWriteFloat(stream, &curve->points[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,8 @@ void curveLoad(PackStream* stream, Curve* curve)
|
|||
packReadInt(stream, &curve->nbpoints);
|
||||
for (i = 0; i < curve->nbpoints; i++)
|
||||
{
|
||||
packReadDouble(stream, &curve->points[i].position);
|
||||
packReadDouble(stream, &curve->points[i].value);
|
||||
packReadFloat(stream, &curve->points[i].position);
|
||||
packReadFloat(stream, &curve->points[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ int curveAddPoint(Curve* curve, CurvePoint* point)
|
|||
}
|
||||
}
|
||||
|
||||
int curveQuickAddPoint(Curve* curve, double position, double value)
|
||||
int curveQuickAddPoint(Curve* curve, float position, float value)
|
||||
{
|
||||
CurvePoint point;
|
||||
|
||||
|
@ -137,10 +137,10 @@ void curveValidate(Curve* curve)
|
|||
}
|
||||
}
|
||||
|
||||
double curveGetValue(Curve* curve, double position)
|
||||
float curveGetValue(Curve* curve, float position)
|
||||
{
|
||||
int i;
|
||||
double fact;
|
||||
float fact;
|
||||
|
||||
if (curve->nbpoints == 0)
|
||||
{
|
||||
|
|
|
@ -8,8 +8,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct {
|
||||
double position;
|
||||
double value;
|
||||
float position;
|
||||
float value;
|
||||
} CurvePoint;
|
||||
typedef struct Curve Curve;
|
||||
|
||||
|
@ -22,14 +22,14 @@ void curveLoad(PackStream* stream, Curve* curve);
|
|||
|
||||
void curveClear(Curve* curve);
|
||||
int curveAddPoint(Curve* curve, CurvePoint* point);
|
||||
int curveQuickAddPoint(Curve* curve, double position, double value);
|
||||
int curveQuickAddPoint(Curve* curve, float position, float value);
|
||||
int curveGetPointCount(Curve* curve);
|
||||
void curveGetPoint(Curve* curve, int number, CurvePoint* point);
|
||||
void curveSetPoint(Curve* curve, int number, CurvePoint* point);
|
||||
void curveRemovePoint(Curve* curve, int number);
|
||||
void curveValidate(Curve* curve);
|
||||
|
||||
double curveGetValue(Curve* curve, double position);
|
||||
float curveGetValue(Curve* curve, float position);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -8,19 +8,19 @@ Vector3 VECTOR_ZERO = {0.0, 0.0, 0.0};
|
|||
|
||||
void v3Save(PackStream* stream, Vector3* v)
|
||||
{
|
||||
packWriteDouble(stream, &v->x);
|
||||
packWriteDouble(stream, &v->y);
|
||||
packWriteDouble(stream, &v->z);
|
||||
packWriteFloat(stream, &v->x);
|
||||
packWriteFloat(stream, &v->y);
|
||||
packWriteFloat(stream, &v->z);
|
||||
}
|
||||
|
||||
void v3Load(PackStream* stream, Vector3* v)
|
||||
{
|
||||
packReadDouble(stream, &v->x);
|
||||
packReadDouble(stream, &v->y);
|
||||
packReadDouble(stream, &v->z);
|
||||
packReadFloat(stream, &v->x);
|
||||
packReadFloat(stream, &v->y);
|
||||
packReadFloat(stream, &v->z);
|
||||
}
|
||||
|
||||
Vector3 v3Translate(Vector3 v1, double x, double y, double z)
|
||||
Vector3 v3Translate(Vector3 v1, float x, float y, float z)
|
||||
{
|
||||
Vector3 result;
|
||||
result.x = v1.x + x;
|
||||
|
@ -56,7 +56,7 @@ Vector3 v3Neg(Vector3 v)
|
|||
return result;
|
||||
}
|
||||
|
||||
Vector3 v3Scale(Vector3 v, double scale)
|
||||
Vector3 v3Scale(Vector3 v, float scale)
|
||||
{
|
||||
Vector3 result;
|
||||
result.x = v.x * scale;
|
||||
|
@ -65,14 +65,14 @@ Vector3 v3Scale(Vector3 v, double scale)
|
|||
return result;
|
||||
}
|
||||
|
||||
double v3Norm(Vector3 v)
|
||||
float v3Norm(Vector3 v)
|
||||
{
|
||||
return sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
}
|
||||
|
||||
Vector3 v3Normalize(Vector3 v)
|
||||
{
|
||||
double norm = v3Norm(v);
|
||||
float norm = v3Norm(v);
|
||||
if (norm == 0.0)
|
||||
{
|
||||
return VECTOR_ZERO;
|
||||
|
@ -83,7 +83,7 @@ Vector3 v3Normalize(Vector3 v)
|
|||
}
|
||||
}
|
||||
|
||||
double v3Dot(Vector3 v1, Vector3 v2)
|
||||
float v3Dot(Vector3 v1, Vector3 v2)
|
||||
{
|
||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
||||
}
|
||||
|
@ -99,42 +99,42 @@ Vector3 v3Cross(Vector3 v1, Vector3 v2)
|
|||
|
||||
void m4Save(PackStream* stream, Matrix4* m)
|
||||
{
|
||||
packWriteDouble(stream, &m->a);
|
||||
packWriteDouble(stream, &m->b);
|
||||
packWriteDouble(stream, &m->c);
|
||||
packWriteDouble(stream, &m->d);
|
||||
packWriteDouble(stream, &m->e);
|
||||
packWriteDouble(stream, &m->f);
|
||||
packWriteDouble(stream, &m->g);
|
||||
packWriteDouble(stream, &m->h);
|
||||
packWriteDouble(stream, &m->i);
|
||||
packWriteDouble(stream, &m->j);
|
||||
packWriteDouble(stream, &m->k);
|
||||
packWriteDouble(stream, &m->l);
|
||||
packWriteDouble(stream, &m->m);
|
||||
packWriteDouble(stream, &m->n);
|
||||
packWriteDouble(stream, &m->o);
|
||||
packWriteDouble(stream, &m->p);
|
||||
packWriteFloat(stream, &m->a);
|
||||
packWriteFloat(stream, &m->b);
|
||||
packWriteFloat(stream, &m->c);
|
||||
packWriteFloat(stream, &m->d);
|
||||
packWriteFloat(stream, &m->e);
|
||||
packWriteFloat(stream, &m->f);
|
||||
packWriteFloat(stream, &m->g);
|
||||
packWriteFloat(stream, &m->h);
|
||||
packWriteFloat(stream, &m->i);
|
||||
packWriteFloat(stream, &m->j);
|
||||
packWriteFloat(stream, &m->k);
|
||||
packWriteFloat(stream, &m->l);
|
||||
packWriteFloat(stream, &m->m);
|
||||
packWriteFloat(stream, &m->n);
|
||||
packWriteFloat(stream, &m->o);
|
||||
packWriteFloat(stream, &m->p);
|
||||
}
|
||||
|
||||
void m4Load(PackStream* stream, Matrix4* m)
|
||||
{
|
||||
packReadDouble(stream, &m->a);
|
||||
packReadDouble(stream, &m->b);
|
||||
packReadDouble(stream, &m->c);
|
||||
packReadDouble(stream, &m->d);
|
||||
packReadDouble(stream, &m->e);
|
||||
packReadDouble(stream, &m->f);
|
||||
packReadDouble(stream, &m->g);
|
||||
packReadDouble(stream, &m->h);
|
||||
packReadDouble(stream, &m->i);
|
||||
packReadDouble(stream, &m->j);
|
||||
packReadDouble(stream, &m->k);
|
||||
packReadDouble(stream, &m->l);
|
||||
packReadDouble(stream, &m->m);
|
||||
packReadDouble(stream, &m->n);
|
||||
packReadDouble(stream, &m->o);
|
||||
packReadDouble(stream, &m->p);
|
||||
packReadFloat(stream, &m->a);
|
||||
packReadFloat(stream, &m->b);
|
||||
packReadFloat(stream, &m->c);
|
||||
packReadFloat(stream, &m->d);
|
||||
packReadFloat(stream, &m->e);
|
||||
packReadFloat(stream, &m->f);
|
||||
packReadFloat(stream, &m->g);
|
||||
packReadFloat(stream, &m->h);
|
||||
packReadFloat(stream, &m->i);
|
||||
packReadFloat(stream, &m->j);
|
||||
packReadFloat(stream, &m->k);
|
||||
packReadFloat(stream, &m->l);
|
||||
packReadFloat(stream, &m->m);
|
||||
packReadFloat(stream, &m->n);
|
||||
packReadFloat(stream, &m->o);
|
||||
packReadFloat(stream, &m->p);
|
||||
}
|
||||
|
||||
Matrix4 m4NewIdentity()
|
||||
|
@ -180,7 +180,7 @@ Vector3 m4MultPoint(Matrix4 m, Vector3 v)
|
|||
Vector3 m4Transform(Matrix4 m, Vector3 v)
|
||||
{
|
||||
Vector3 result;
|
||||
double w;
|
||||
float w;
|
||||
result.x = m.a * v.x + m.b * v.y + m.c * v.z + m.d;
|
||||
result.y = m.e * v.x + m.f * v.y + m.g * v.z + m.h;
|
||||
result.z = m.i * v.x + m.j * v.y + m.k * v.z + m.l;
|
||||
|
@ -216,7 +216,7 @@ Matrix4 m4Transpose(Matrix4 m)
|
|||
return result;
|
||||
}
|
||||
|
||||
Matrix4 m4NewScale(double x, double y, double z)
|
||||
Matrix4 m4NewScale(float x, float y, float z)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
result.a = x;
|
||||
|
@ -225,7 +225,7 @@ Matrix4 m4NewScale(double x, double y, double z)
|
|||
return result;
|
||||
}
|
||||
|
||||
Matrix4 m4NewTranslate(double x, double y, double z)
|
||||
Matrix4 m4NewTranslate(float x, float y, float z)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
result.d = x;
|
||||
|
@ -234,45 +234,45 @@ Matrix4 m4NewTranslate(double x, double y, double z)
|
|||
return result;
|
||||
}
|
||||
|
||||
Matrix4 m4NewRotateX(double angle)
|
||||
Matrix4 m4NewRotateX(float angle)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
float s = sin(angle);
|
||||
float c = cos(angle);
|
||||
result.f = result.k = c;
|
||||
result.g = -s;
|
||||
result.j = s;
|
||||
return result;
|
||||
}
|
||||
|
||||
Matrix4 m4NewRotateY(double angle)
|
||||
Matrix4 m4NewRotateY(float angle)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
float s = sin(angle);
|
||||
float c = cos(angle);
|
||||
result.a = result.k = c;
|
||||
result.c = s;
|
||||
result.i = -s;
|
||||
return result;
|
||||
}
|
||||
|
||||
Matrix4 m4NewRotateZ(double angle)
|
||||
Matrix4 m4NewRotateZ(float angle)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
float s = sin(angle);
|
||||
float c = cos(angle);
|
||||
result.a = result.f = c;
|
||||
result.b = -s;
|
||||
result.e = s;
|
||||
return result;
|
||||
}
|
||||
|
||||
Matrix4 m4NewRotateAxis(double angle, Vector3 axis)
|
||||
Matrix4 m4NewRotateAxis(float angle, Vector3 axis)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
double s = sin(angle);
|
||||
double c = cos(angle);
|
||||
double c1 = 1.0 - c;
|
||||
float s = sin(angle);
|
||||
float c = cos(angle);
|
||||
float c1 = 1.0 - c;
|
||||
axis = v3Normalize(axis);
|
||||
result.a = axis.x * axis.x * c1 + c;
|
||||
result.b = axis.x * axis.y * c1 - axis.z * s;
|
||||
|
@ -286,15 +286,15 @@ Matrix4 m4NewRotateAxis(double angle, Vector3 axis)
|
|||
return result;
|
||||
}
|
||||
|
||||
Matrix4 m4NewRotateEuler(double heading, double attitude, double bank)
|
||||
Matrix4 m4NewRotateEuler(float heading, float attitude, float bank)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
double ch = cos(heading);
|
||||
double sh = sin(heading);
|
||||
double ca = cos(attitude);
|
||||
double sa = sin(attitude);
|
||||
double cb = cos(bank);
|
||||
double sb = sin(bank);
|
||||
float ch = cos(heading);
|
||||
float sh = sin(heading);
|
||||
float ca = cos(attitude);
|
||||
float sa = sin(attitude);
|
||||
float cb = cos(bank);
|
||||
float sb = sin(bank);
|
||||
result.a = ch * ca;
|
||||
result.b = sh * sb - ch * sa * cb;
|
||||
result.c = ch * sa * sb + sh * cb;
|
||||
|
@ -334,10 +334,10 @@ Matrix4 m4NewLookAt(Vector3 eye, Vector3 at, Vector3 up)
|
|||
return m4Inverse(result);
|
||||
}
|
||||
|
||||
Matrix4 m4NewPerspective(double fov_y, double aspect, double near, double far)
|
||||
Matrix4 m4NewPerspective(float fov_y, float aspect, float near, float far)
|
||||
{
|
||||
Matrix4 result = m4NewIdentity();
|
||||
double f = 1 / tan(fov_y / 2.0);
|
||||
float f = 1 / tan(fov_y / 2.0);
|
||||
result.a = f / aspect;
|
||||
result.f = f;
|
||||
result.k = (far + near) / (near - far);
|
||||
|
@ -347,7 +347,7 @@ Matrix4 m4NewPerspective(double fov_y, double aspect, double near, double far)
|
|||
return result;
|
||||
}
|
||||
|
||||
double m4Determinant(Matrix4 m)
|
||||
float m4Determinant(Matrix4 m)
|
||||
{
|
||||
return ((m.a * m.f - m.e * m.b)
|
||||
* (m.k * m.p - m.o * m.l)
|
||||
|
@ -366,7 +366,7 @@ double m4Determinant(Matrix4 m)
|
|||
Matrix4 m4Inverse(Matrix4 m)
|
||||
{
|
||||
Matrix4 result;
|
||||
double d = m4Determinant(m);
|
||||
float d = m4Determinant(m);
|
||||
|
||||
if (fabs(d) < 0.00001)
|
||||
{
|
||||
|
|
|
@ -9,43 +9,43 @@ extern "C" {
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Vector3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double a;
|
||||
double b;
|
||||
double c;
|
||||
double d;
|
||||
double e;
|
||||
double f;
|
||||
double g;
|
||||
double h;
|
||||
double i;
|
||||
double j;
|
||||
double k;
|
||||
double l;
|
||||
double m;
|
||||
double n;
|
||||
double o;
|
||||
double p;
|
||||
float a;
|
||||
float b;
|
||||
float c;
|
||||
float d;
|
||||
float e;
|
||||
float f;
|
||||
float g;
|
||||
float h;
|
||||
float i;
|
||||
float j;
|
||||
float k;
|
||||
float l;
|
||||
float m;
|
||||
float n;
|
||||
float o;
|
||||
float p;
|
||||
} Matrix4;
|
||||
|
||||
extern Vector3 VECTOR_ZERO;
|
||||
|
||||
void v3Save(PackStream* stream, Vector3* v);
|
||||
void v3Load(PackStream* stream, Vector3* v);
|
||||
Vector3 v3Translate(Vector3 v1, double x, double y, double z);
|
||||
Vector3 v3Translate(Vector3 v1, float x, float y, float z);
|
||||
Vector3 v3Add(Vector3 v1, Vector3 v2);
|
||||
Vector3 v3Sub(Vector3 v1, Vector3 v2);
|
||||
Vector3 v3Neg(Vector3 v);
|
||||
Vector3 v3Scale(Vector3 v, double scale);
|
||||
double v3Norm(Vector3 v);
|
||||
Vector3 v3Scale(Vector3 v, float scale);
|
||||
float v3Norm(Vector3 v);
|
||||
Vector3 v3Normalize(Vector3 v);
|
||||
double v3Dot(Vector3 v1, Vector3 v2);
|
||||
float v3Dot(Vector3 v1, Vector3 v2);
|
||||
Vector3 v3Cross(Vector3 v1, Vector3 v2);
|
||||
|
||||
void m4Save(PackStream* stream, Matrix4* m);
|
||||
|
@ -55,17 +55,17 @@ Matrix4 m4Mult(Matrix4 m1, Matrix4 m2);
|
|||
Vector3 m4MultPoint(Matrix4 m, Vector3 v);
|
||||
Vector3 m4Transform(Matrix4 m, Vector3 v);
|
||||
Matrix4 m4Transpose(Matrix4 m);
|
||||
Matrix4 m4NewScale(double x, double y, double z);
|
||||
Matrix4 m4NewTranslate(double x, double y, double z);
|
||||
Matrix4 m4NewRotateX(double angle);
|
||||
Matrix4 m4NewRotateY(double angle);
|
||||
Matrix4 m4NewRotateZ(double angle);
|
||||
Matrix4 m4NewRotateAxis(double angle, Vector3 axis);
|
||||
Matrix4 m4NewRotateEuler(double heading, double attitude, double bank);
|
||||
Matrix4 m4NewScale(float x, float y, float z);
|
||||
Matrix4 m4NewTranslate(float x, float y, float z);
|
||||
Matrix4 m4NewRotateX(float angle);
|
||||
Matrix4 m4NewRotateY(float angle);
|
||||
Matrix4 m4NewRotateZ(float angle);
|
||||
Matrix4 m4NewRotateAxis(float angle, Vector3 axis);
|
||||
Matrix4 m4NewRotateEuler(float heading, float attitude, float bank);
|
||||
Matrix4 m4NewRotateTripleAxis(Vector3 x, Vector3 y, Vector3 z);
|
||||
Matrix4 m4NewLookAt(Vector3 eye, Vector3 at, Vector3 up);
|
||||
Matrix4 m4NewPerspective(double fov_y, double aspect, double near, double far);
|
||||
double m4Determinant(Matrix4 m);
|
||||
Matrix4 m4NewPerspective(float fov_y, float aspect, float near, float far);
|
||||
float m4Determinant(Matrix4 m);
|
||||
Matrix4 m4Inverse(Matrix4 m);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -43,10 +43,10 @@ void lightingSave(PackStream* stream, LightingDefinition* definition)
|
|||
{
|
||||
v3Save(stream, &definition->lights[i].direction);
|
||||
colorSave(stream, &definition->lights[i].color);
|
||||
packWriteDouble(stream, &definition->lights[i].reflection);
|
||||
packWriteFloat(stream, &definition->lights[i].reflection);
|
||||
packWriteInt(stream, &definition->lights[i].filtered);
|
||||
packWriteInt(stream, &definition->lights[i].masked);
|
||||
packWriteDouble(stream, &definition->lights[i].amplitude);
|
||||
packWriteFloat(stream, &definition->lights[i].amplitude);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,10 +60,10 @@ void lightingLoad(PackStream* stream, LightingDefinition* definition)
|
|||
{
|
||||
v3Load(stream, &definition->lights[i].direction);
|
||||
colorLoad(stream, &definition->lights[i].color);
|
||||
packReadDouble(stream, &definition->lights[i].reflection);
|
||||
packReadFloat(stream, &definition->lights[i].reflection);
|
||||
packReadInt(stream, &definition->lights[i].filtered);
|
||||
packReadInt(stream, &definition->lights[i].masked);
|
||||
packReadDouble(stream, &definition->lights[i].amplitude);
|
||||
packReadFloat(stream, &definition->lights[i].amplitude);
|
||||
}
|
||||
|
||||
lightingValidateDefinition(definition);
|
||||
|
@ -170,7 +170,7 @@ static int _getLightStatus(LightDefinition* definition, Renderer* renderer, Vect
|
|||
static Color _applyDirectLight(LightDefinition* definition, Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial material)
|
||||
{
|
||||
Color result, light;
|
||||
double diffuse, specular, normal_norm;
|
||||
float diffuse, specular, normal_norm;
|
||||
Vector3 view, reflect, direction_inv;
|
||||
|
||||
light = definition->color;
|
||||
|
@ -180,16 +180,16 @@ static Color _applyDirectLight(LightDefinition* definition, Renderer* renderer,
|
|||
{
|
||||
/* TODO Sampling around light direction */
|
||||
int xsamples, ysamples, samples, x, y;
|
||||
double xstep, ystep, factor;
|
||||
float xstep, ystep, factor;
|
||||
LightDefinition sublight;
|
||||
|
||||
ysamples = renderer->render_quality / 4 + 1;
|
||||
xsamples = renderer->render_quality / 2 + 1;
|
||||
samples = xsamples * ysamples + 1;
|
||||
factor = 1.0 / (double)samples;
|
||||
factor = 1.0 / (float)samples;
|
||||
|
||||
xstep = M_PI * 2.0 / (double)xsamples;
|
||||
ystep = M_PI * 0.5 / (double)(ysamples - 1);
|
||||
xstep = M_PI * 2.0 / (float)xsamples;
|
||||
ystep = M_PI * 0.5 / (float)(ysamples - 1);
|
||||
|
||||
sublight = *definition;
|
||||
sublight.amplitude = 0.0;
|
||||
|
|
|
@ -15,10 +15,10 @@ struct LightDefinition
|
|||
{
|
||||
Vector3 direction; /* Global direction of the light */
|
||||
Color color; /* Main color of the light */
|
||||
double reflection; /* Reflected factor of the light (for specular lighting) */
|
||||
float reflection; /* Reflected factor of the light (for specular lighting) */
|
||||
int filtered; /* Should the light be filtered (by atmosphere, water...) */
|
||||
int masked; /* Should the light be masked (cast shadows..) */
|
||||
double amplitude; /* Angle amplitude of the light source (for multi-sampling, pi / 2.0 for skydome) */
|
||||
float amplitude; /* Angle amplitude of the light source (for multi-sampling, pi / 2.0 for skydome) */
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "render.h"
|
||||
#include "main.h"
|
||||
|
||||
#define APP_HEADER 1986325632.125
|
||||
#define APP_HEADER 198632.125
|
||||
|
||||
void paysagesInit()
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ void paysagesInit()
|
|||
autoSetDaytime(8, 30);
|
||||
|
||||
// DEBUG
|
||||
/*double last_height, height, x;
|
||||
/*float last_height, height, x;
|
||||
last_height = height = 0.0;
|
||||
x = 0.0;
|
||||
while (height <= 1.0 || height >= last_height || last_height < 0.1)
|
||||
|
@ -60,17 +60,17 @@ void paysagesQuit()
|
|||
FileOperationResult paysagesSave(char* filepath)
|
||||
{
|
||||
PackStream* stream = packWriteFile(filepath);
|
||||
double app_header, version_header;
|
||||
float app_header, version_header;
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
app_header = (double)APP_HEADER;
|
||||
packWriteDouble(stream, &app_header);
|
||||
version_header = (double)PAYSAGES_CURRENT_DATA_VERSION;
|
||||
packWriteDouble(stream, &version_header);
|
||||
app_header = (float)APP_HEADER;
|
||||
packWriteFloat(stream, &app_header);
|
||||
version_header = (float)PAYSAGES_CURRENT_DATA_VERSION;
|
||||
packWriteFloat(stream, &version_header);
|
||||
|
||||
scenerySave(stream);
|
||||
|
||||
|
@ -82,21 +82,21 @@ FileOperationResult paysagesSave(char* filepath)
|
|||
FileOperationResult paysagesLoad(char* filepath)
|
||||
{
|
||||
PackStream* stream = packReadFile(filepath);
|
||||
double app_header, version_header;
|
||||
float app_header, version_header;
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
return FILE_OPERATION_IOERROR;
|
||||
}
|
||||
|
||||
packReadDouble(stream, &app_header);
|
||||
packReadFloat(stream, &app_header);
|
||||
if (app_header != APP_HEADER)
|
||||
{
|
||||
packCloseStream(stream);
|
||||
return FILE_OPERATION_APP_MISMATCH;
|
||||
}
|
||||
|
||||
packReadDouble(stream, &version_header);
|
||||
packReadFloat(stream, &version_header);
|
||||
if ((int)version_header != PAYSAGES_CURRENT_DATA_VERSION)
|
||||
{
|
||||
packCloseStream(stream);
|
||||
|
|
|
@ -13,7 +13,7 @@ struct HeightModifier
|
|||
{
|
||||
Zone* zone;
|
||||
int mode;
|
||||
double value;
|
||||
float value;
|
||||
};
|
||||
|
||||
HeightModifier* modifierCreate()
|
||||
|
@ -49,14 +49,14 @@ void modifierDelete(HeightModifier* modifier)
|
|||
void modifierSave(PackStream* stream, HeightModifier* modifier)
|
||||
{
|
||||
packWriteInt(stream, &modifier->mode);
|
||||
packWriteDouble(stream, &modifier->value);
|
||||
packWriteFloat(stream, &modifier->value);
|
||||
zoneSave(stream, modifier->zone);
|
||||
}
|
||||
|
||||
void modifierLoad(PackStream* stream, HeightModifier* modifier)
|
||||
{
|
||||
packReadInt(stream, &modifier->mode);
|
||||
packReadDouble(stream, &modifier->value);
|
||||
packReadFloat(stream, &modifier->value);
|
||||
zoneLoad(stream, modifier->zone);
|
||||
}
|
||||
|
||||
|
@ -65,13 +65,13 @@ Zone* modifierGetZone(HeightModifier* modifier)
|
|||
return modifier->zone;
|
||||
}
|
||||
|
||||
void modifierActionAddValue(HeightModifier* modifier, double value)
|
||||
void modifierActionAddValue(HeightModifier* modifier, float value)
|
||||
{
|
||||
modifier->mode = MODE_ADD_VALUE;
|
||||
modifier->value = value;
|
||||
}
|
||||
|
||||
void modifierActionFixValue(HeightModifier* modifier, double value)
|
||||
void modifierActionFixValue(HeightModifier* modifier, float value)
|
||||
{
|
||||
modifier->mode = MODE_FIX_VALUE;
|
||||
modifier->value = value;
|
||||
|
@ -79,7 +79,7 @@ void modifierActionFixValue(HeightModifier* modifier, double value)
|
|||
|
||||
Vector3 modifierApply(HeightModifier* modifier, Vector3 location)
|
||||
{
|
||||
double influence, diff;
|
||||
float influence, diff;
|
||||
Vector3 normal;
|
||||
|
||||
switch (modifier->mode)
|
||||
|
|
|
@ -16,8 +16,8 @@ void modifierDelete(HeightModifier* modifier);
|
|||
void modifierSave(PackStream* stream, HeightModifier* modifier);
|
||||
void modifierLoad(PackStream* stream, HeightModifier* modifier);
|
||||
Zone* modifierGetZone(HeightModifier* modifier);
|
||||
void modifierActionAddValue(HeightModifier* modifier, double value);
|
||||
void modifierActionFixValue(HeightModifier* modifier, double value);
|
||||
void modifierActionAddValue(HeightModifier* modifier, float value);
|
||||
void modifierActionFixValue(HeightModifier* modifier, float value);
|
||||
Vector3 modifierApply(HeightModifier* modifier, Vector3 location);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -15,15 +15,15 @@ struct NoiseGenerator
|
|||
int size1;
|
||||
int size2;
|
||||
int size3;
|
||||
double height_offset;
|
||||
float height_offset;
|
||||
int level_count;
|
||||
struct NoiseLevel levels[MAX_LEVEL_COUNT];
|
||||
};
|
||||
|
||||
static int _noise_pool_size;
|
||||
static double* _noise_pool;
|
||||
static float* _noise_pool;
|
||||
|
||||
static inline double _cubicInterpolate(double* p, double x)
|
||||
static inline float _cubicInterpolate(float* p, float x)
|
||||
{
|
||||
return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ void noiseInit()
|
|||
int i;
|
||||
|
||||
_noise_pool_size = 1048576;
|
||||
_noise_pool = malloc(sizeof(double) * _noise_pool_size);
|
||||
_noise_pool = malloc(sizeof(float) * _noise_pool_size);
|
||||
|
||||
for (i = 0; i < _noise_pool_size; i++)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ void noiseSave(PackStream* stream)
|
|||
packWriteInt(stream, &_noise_pool_size);
|
||||
for (i = 0; i < _noise_pool_size; i++)
|
||||
{
|
||||
packWriteDouble(stream, _noise_pool + i);
|
||||
packWriteFloat(stream, _noise_pool + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,10 +62,10 @@ void noiseLoad(PackStream* stream)
|
|||
int i;
|
||||
|
||||
packReadInt(stream, &_noise_pool_size);
|
||||
_noise_pool = realloc(_noise_pool, sizeof(double) * _noise_pool_size);
|
||||
_noise_pool = realloc(_noise_pool, sizeof(float) * _noise_pool_size);
|
||||
for (i = 0; i < _noise_pool_size; i++)
|
||||
{
|
||||
packReadDouble(stream, _noise_pool + i);
|
||||
packReadFloat(stream, _noise_pool + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,18 +96,18 @@ void noiseSaveGenerator(PackStream* stream, NoiseGenerator* perlin)
|
|||
packWriteInt(stream, &perlin->size1);
|
||||
packWriteInt(stream, &perlin->size2);
|
||||
packWriteInt(stream, &perlin->size3);
|
||||
packWriteDouble(stream, &perlin->height_offset);
|
||||
packWriteFloat(stream, &perlin->height_offset);
|
||||
packWriteInt(stream, &perlin->level_count);
|
||||
|
||||
for (x = 0; x < perlin->level_count; x++)
|
||||
{
|
||||
NoiseLevel* level = perlin->levels + x;
|
||||
|
||||
packWriteDouble(stream, &level->scaling);
|
||||
packWriteDouble(stream, &level->height);
|
||||
packWriteDouble(stream, &level->xoffset);
|
||||
packWriteDouble(stream, &level->yoffset);
|
||||
packWriteDouble(stream, &level->zoffset);
|
||||
packWriteFloat(stream, &level->scaling);
|
||||
packWriteFloat(stream, &level->height);
|
||||
packWriteFloat(stream, &level->xoffset);
|
||||
packWriteFloat(stream, &level->yoffset);
|
||||
packWriteFloat(stream, &level->zoffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,18 +118,18 @@ void noiseLoadGenerator(PackStream* stream, NoiseGenerator* perlin)
|
|||
packReadInt(stream, &perlin->size1);
|
||||
packReadInt(stream, &perlin->size2);
|
||||
packReadInt(stream, &perlin->size3);
|
||||
packReadDouble(stream, &perlin->height_offset);
|
||||
packReadFloat(stream, &perlin->height_offset);
|
||||
packReadInt(stream, &perlin->level_count);
|
||||
|
||||
for (x = 0; x < perlin->level_count; x++)
|
||||
{
|
||||
NoiseLevel* level = perlin->levels + x;
|
||||
|
||||
packReadDouble(stream, &level->scaling);
|
||||
packReadDouble(stream, &level->height);
|
||||
packReadDouble(stream, &level->xoffset);
|
||||
packReadDouble(stream, &level->yoffset);
|
||||
packReadDouble(stream, &level->zoffset);
|
||||
packReadFloat(stream, &level->scaling);
|
||||
packReadFloat(stream, &level->height);
|
||||
packReadFloat(stream, &level->xoffset);
|
||||
packReadFloat(stream, &level->yoffset);
|
||||
packReadFloat(stream, &level->zoffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,10 +159,10 @@ int noiseGetBaseSize(NoiseGenerator* generator)
|
|||
return generator->size1;
|
||||
}
|
||||
|
||||
double noiseGetMaxValue(NoiseGenerator* generator)
|
||||
float noiseGetMaxValue(NoiseGenerator* generator)
|
||||
{
|
||||
int x;
|
||||
double result = generator->height_offset;
|
||||
float result = generator->height_offset;
|
||||
|
||||
for (x = 0; x < generator->level_count; x++)
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ void noiseAddLevel(NoiseGenerator* generator, NoiseLevel level)
|
|||
}
|
||||
}
|
||||
|
||||
void noiseAddLevelSimple(NoiseGenerator* generator, double scaling, double height)
|
||||
void noiseAddLevelSimple(NoiseGenerator* generator, float scaling, float height)
|
||||
{
|
||||
NoiseLevel level;
|
||||
|
||||
|
@ -204,7 +204,7 @@ void noiseAddLevelSimple(NoiseGenerator* generator, double scaling, double heigh
|
|||
noiseAddLevel(generator, level);
|
||||
}
|
||||
|
||||
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, double scaling_factor, double height_factor, int randomize_offset)
|
||||
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, float scaling_factor, float height_factor, int randomize_offset)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -222,7 +222,7 @@ void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start
|
|||
}
|
||||
}
|
||||
|
||||
void noiseAddLevelsSimple(NoiseGenerator* generator, int level_count, double scaling, double height)
|
||||
void noiseAddLevelsSimple(NoiseGenerator* generator, int level_count, float scaling, float height)
|
||||
{
|
||||
NoiseLevel level;
|
||||
|
||||
|
@ -264,7 +264,7 @@ void noiseSetLevel(NoiseGenerator* generator, int level, NoiseLevel params)
|
|||
}
|
||||
}
|
||||
|
||||
void noiseSetLevelSimple(NoiseGenerator* generator, int level, double scaling, double height)
|
||||
void noiseSetLevelSimple(NoiseGenerator* generator, int level, float scaling, float height)
|
||||
{
|
||||
NoiseLevel params;
|
||||
|
||||
|
@ -277,11 +277,11 @@ void noiseSetLevelSimple(NoiseGenerator* generator, int level, double scaling, d
|
|||
noiseSetLevel(generator, level, params);
|
||||
}
|
||||
|
||||
void noiseNormalizeHeight(NoiseGenerator* generator, double min_height, double max_height, int adjust_scaling)
|
||||
void noiseNormalizeHeight(NoiseGenerator* generator, float min_height, float max_height, int adjust_scaling)
|
||||
{
|
||||
int level;
|
||||
double height = 0.0;
|
||||
double target_height = max_height - min_height;
|
||||
float height = 0.0;
|
||||
float target_height = max_height - min_height;
|
||||
|
||||
if (generator->level_count == 0)
|
||||
{
|
||||
|
@ -306,13 +306,13 @@ void noiseNormalizeHeight(NoiseGenerator* generator, double min_height, double m
|
|||
|
||||
|
||||
|
||||
static inline double _get1DRawNoiseValue(NoiseGenerator* generator, double x)
|
||||
static inline float _get1DRawNoiseValue(NoiseGenerator* generator, float x)
|
||||
{
|
||||
int size = generator->size1;
|
||||
|
||||
int xbase = (int)floor(x);
|
||||
|
||||
double xinternal = x - (double)xbase;
|
||||
float xinternal = x - (float)xbase;
|
||||
|
||||
int x0 = (xbase - 1) % size;
|
||||
if (x0 < 0)
|
||||
|
@ -335,7 +335,7 @@ static inline double _get1DRawNoiseValue(NoiseGenerator* generator, double x)
|
|||
x3 += size;
|
||||
}
|
||||
|
||||
double buf_cubic_x[4];
|
||||
float buf_cubic_x[4];
|
||||
|
||||
buf_cubic_x[0] = _noise_pool[x0 % _noise_pool_size];
|
||||
buf_cubic_x[1] = _noise_pool[x1 % _noise_pool_size];
|
||||
|
@ -345,12 +345,12 @@ static inline double _get1DRawNoiseValue(NoiseGenerator* generator, double x)
|
|||
return _cubicInterpolate(buf_cubic_x, xinternal);
|
||||
}
|
||||
|
||||
static inline double _get1DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x)
|
||||
static inline float _get1DLevelValue(NoiseGenerator* generator, NoiseLevel* level, float x)
|
||||
{
|
||||
return _get1DRawNoiseValue(generator, x / level->scaling + level->xoffset * generator->size1) * level->height;
|
||||
}
|
||||
|
||||
double noiseGet1DLevel(NoiseGenerator* generator, int level, double x)
|
||||
float noiseGet1DLevel(NoiseGenerator* generator, int level, float x)
|
||||
{
|
||||
if (level >= 0 && level < generator->level_count)
|
||||
{
|
||||
|
@ -362,10 +362,10 @@ double noiseGet1DLevel(NoiseGenerator* generator, int level, double x)
|
|||
}
|
||||
}
|
||||
|
||||
double noiseGet1DTotal(NoiseGenerator* generator, double x)
|
||||
float noiseGet1DTotal(NoiseGenerator* generator, float x)
|
||||
{
|
||||
int level;
|
||||
double result;
|
||||
float result;
|
||||
|
||||
result = 0.0;
|
||||
for (level = 0; level < generator->level_count; level++)
|
||||
|
@ -375,10 +375,10 @@ double noiseGet1DTotal(NoiseGenerator* generator, double x)
|
|||
return result + generator->height_offset;
|
||||
}
|
||||
|
||||
double noiseGet1DDetail(NoiseGenerator* generator, double x, double detail)
|
||||
float noiseGet1DDetail(NoiseGenerator* generator, float x, float detail)
|
||||
{
|
||||
int level;
|
||||
double result, height, factor;
|
||||
float result, height, factor;
|
||||
|
||||
result = 0.0;
|
||||
for (level = 0; level < generator->level_count; level++)
|
||||
|
@ -402,15 +402,15 @@ double noiseGet1DDetail(NoiseGenerator* generator, double x, double detail)
|
|||
|
||||
|
||||
|
||||
static inline double _get2DRawNoiseValue(NoiseGenerator* generator, double x, double y)
|
||||
static inline float _get2DRawNoiseValue(NoiseGenerator* generator, float x, float y)
|
||||
{
|
||||
int size = generator->size2;
|
||||
|
||||
int xbase = (int)floor(x);
|
||||
int ybase = (int)floor(y);
|
||||
|
||||
double xinternal = x - (double)xbase;
|
||||
double yinternal = y - (double)ybase;
|
||||
float xinternal = x - (float)xbase;
|
||||
float yinternal = y - (float)ybase;
|
||||
|
||||
int x0 = (xbase - 1) % size;
|
||||
if (x0 < 0)
|
||||
|
@ -454,8 +454,8 @@ static inline double _get2DRawNoiseValue(NoiseGenerator* generator, double x, do
|
|||
y3 += size;
|
||||
}
|
||||
|
||||
double buf_cubic_x[4];
|
||||
double buf_cubic_y[4];
|
||||
float buf_cubic_x[4];
|
||||
float buf_cubic_y[4];
|
||||
|
||||
buf_cubic_x[0] = _noise_pool[(y0 * size + x0) % _noise_pool_size];
|
||||
buf_cubic_x[1] = _noise_pool[(y0 * size + x1) % _noise_pool_size];
|
||||
|
@ -484,12 +484,12 @@ static inline double _get2DRawNoiseValue(NoiseGenerator* generator, double x, do
|
|||
return _cubicInterpolate(buf_cubic_y, yinternal);
|
||||
}
|
||||
|
||||
static inline double _get2DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x, double y)
|
||||
static inline float _get2DLevelValue(NoiseGenerator* generator, NoiseLevel* level, float x, float y)
|
||||
{
|
||||
return _get2DRawNoiseValue(generator, x / level->scaling + level->xoffset * generator->size2, y / level->scaling + level->yoffset * generator->size2) * level->height;
|
||||
}
|
||||
|
||||
double noiseGet2DLevel(NoiseGenerator* generator, int level, double x, double y)
|
||||
float noiseGet2DLevel(NoiseGenerator* generator, int level, float x, float y)
|
||||
{
|
||||
if (level >= 0 && level < generator->level_count)
|
||||
{
|
||||
|
@ -501,10 +501,10 @@ double noiseGet2DLevel(NoiseGenerator* generator, int level, double x, double y)
|
|||
}
|
||||
}
|
||||
|
||||
double noiseGet2DTotal(NoiseGenerator* generator, double x, double y)
|
||||
float noiseGet2DTotal(NoiseGenerator* generator, float x, float y)
|
||||
{
|
||||
int level;
|
||||
double result;
|
||||
float result;
|
||||
|
||||
result = 0.0;
|
||||
for (level = 0; level < generator->level_count; level++)
|
||||
|
@ -514,10 +514,10 @@ double noiseGet2DTotal(NoiseGenerator* generator, double x, double y)
|
|||
return result + generator->height_offset;
|
||||
}
|
||||
|
||||
double noiseGet2DDetail(NoiseGenerator* generator, double x, double y, double detail)
|
||||
float noiseGet2DDetail(NoiseGenerator* generator, float x, float y, float detail)
|
||||
{
|
||||
int level;
|
||||
double result, height, factor;
|
||||
float result, height, factor;
|
||||
|
||||
result = 0.0;
|
||||
for (level = 0; level < generator->level_count; level++)
|
||||
|
@ -541,7 +541,7 @@ double noiseGet2DDetail(NoiseGenerator* generator, double x, double y, double de
|
|||
|
||||
|
||||
|
||||
static inline double _get3DRawNoiseValue(NoiseGenerator* generator, double x, double y, double z)
|
||||
static inline float _get3DRawNoiseValue(NoiseGenerator* generator, float x, float y, float z)
|
||||
{
|
||||
int size = generator->size3;
|
||||
|
||||
|
@ -549,9 +549,9 @@ static inline double _get3DRawNoiseValue(NoiseGenerator* generator, double x, do
|
|||
int ybase = (int)floor(y);
|
||||
int zbase = (int)floor(z);
|
||||
|
||||
double xinternal = x - (double)xbase;
|
||||
double yinternal = y - (double)ybase;
|
||||
double zinternal = z - (double)zbase;
|
||||
float xinternal = x - (float)xbase;
|
||||
float yinternal = y - (float)ybase;
|
||||
float zinternal = z - (float)zbase;
|
||||
|
||||
int x0 = (xbase - 1) % size;
|
||||
if (x0 < 0)
|
||||
|
@ -616,9 +616,9 @@ static inline double _get3DRawNoiseValue(NoiseGenerator* generator, double x, do
|
|||
z3 += size;
|
||||
}
|
||||
|
||||
double buf_cubic_x[4];
|
||||
double buf_cubic_y[4];
|
||||
double buf_cubic_z[4];
|
||||
float buf_cubic_x[4];
|
||||
float buf_cubic_y[4];
|
||||
float buf_cubic_z[4];
|
||||
|
||||
buf_cubic_x[0] = _noise_pool[(y0 * size * size + x0 * size + z0) % _noise_pool_size];
|
||||
buf_cubic_x[1] = _noise_pool[(y0 * size * size + x1 * size + z0) % _noise_pool_size];
|
||||
|
@ -727,12 +727,12 @@ static inline double _get3DRawNoiseValue(NoiseGenerator* generator, double x, do
|
|||
return _cubicInterpolate(buf_cubic_z, zinternal);
|
||||
}
|
||||
|
||||
static inline double _get3DLevelValue(NoiseGenerator* generator, NoiseLevel* level, double x, double y, double z)
|
||||
static inline float _get3DLevelValue(NoiseGenerator* generator, NoiseLevel* level, float x, float y, float z)
|
||||
{
|
||||
return _get3DRawNoiseValue(generator, x / level->scaling + level->xoffset * generator->size3, y / level->scaling + level->yoffset * generator->size3, z / level->scaling + level->zoffset * generator->size3) * level->height;
|
||||
}
|
||||
|
||||
double noiseGet3DLevel(NoiseGenerator* generator, int level, double x, double y, double z)
|
||||
float noiseGet3DLevel(NoiseGenerator* generator, int level, float x, float y, float z)
|
||||
{
|
||||
if (level >= 0 && level < generator->level_count)
|
||||
{
|
||||
|
@ -744,10 +744,10 @@ double noiseGet3DLevel(NoiseGenerator* generator, int level, double x, double y,
|
|||
}
|
||||
}
|
||||
|
||||
double noiseGet3DTotal(NoiseGenerator* generator, double x, double y, double z)
|
||||
float noiseGet3DTotal(NoiseGenerator* generator, float x, float y, float z)
|
||||
{
|
||||
int level;
|
||||
double result;
|
||||
float result;
|
||||
|
||||
result = 0.0;
|
||||
for (level = 0; level < generator->level_count; level++)
|
||||
|
@ -757,10 +757,10 @@ double noiseGet3DTotal(NoiseGenerator* generator, double x, double y, double z)
|
|||
return result + generator->height_offset;
|
||||
}
|
||||
|
||||
double noiseGet3DDetail(NoiseGenerator* generator, double x, double y, double z, double detail)
|
||||
float noiseGet3DDetail(NoiseGenerator* generator, float x, float y, float z, float detail)
|
||||
{
|
||||
int level;
|
||||
double result, height, factor;
|
||||
float result, height, factor;
|
||||
|
||||
result = 0.0;
|
||||
for (level = 0; level < generator->level_count; level++)
|
||||
|
|
|
@ -9,11 +9,11 @@ extern "C" {
|
|||
|
||||
struct NoiseLevel
|
||||
{
|
||||
double scaling;
|
||||
double height;
|
||||
double xoffset;
|
||||
double yoffset;
|
||||
double zoffset;
|
||||
float scaling;
|
||||
float height;
|
||||
float xoffset;
|
||||
float yoffset;
|
||||
float zoffset;
|
||||
};
|
||||
typedef struct NoiseLevel NoiseLevel;
|
||||
typedef struct NoiseGenerator NoiseGenerator;
|
||||
|
@ -30,27 +30,27 @@ void noiseLoadGenerator(PackStream* stream, NoiseGenerator* perlin);
|
|||
void noiseCopy(NoiseGenerator* source, NoiseGenerator* destination);
|
||||
void noiseGenerateBaseNoise(NoiseGenerator* generator, int size);
|
||||
int noiseGetBaseSize(NoiseGenerator* generator);
|
||||
double noiseGetMaxValue(NoiseGenerator* generator);
|
||||
float noiseGetMaxValue(NoiseGenerator* generator);
|
||||
int noiseGetLevelCount(NoiseGenerator* generator);
|
||||
void noiseClearLevels(NoiseGenerator* generator);
|
||||
void noiseAddLevel(NoiseGenerator* generator, NoiseLevel level);
|
||||
void noiseAddLevelSimple(NoiseGenerator* generator, double scaling, double height);
|
||||
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, double scaling_factor, double height_factor, int randomize_offset);
|
||||
void noiseAddLevelsSimple(NoiseGenerator* generator, int level_count, double scaling, double height);
|
||||
void noiseAddLevelSimple(NoiseGenerator* generator, float scaling, float height);
|
||||
void noiseAddLevels(NoiseGenerator* generator, int level_count, NoiseLevel start_level, float scaling_factor, float height_factor, int randomize_offset);
|
||||
void noiseAddLevelsSimple(NoiseGenerator* generator, int level_count, float scaling, float height);
|
||||
void noiseRemoveLevel(NoiseGenerator* generator, int level);
|
||||
int noiseGetLevel(NoiseGenerator* generator, int level, NoiseLevel* params);
|
||||
void noiseSetLevel(NoiseGenerator* generator, int level, NoiseLevel params);
|
||||
void noiseSetLevelSimple(NoiseGenerator* generator, int level, double scaling, double height);
|
||||
void noiseNormalizeHeight(NoiseGenerator* generator, double min_height, double max_height, int adjust_scaling);
|
||||
double noiseGet1DLevel(NoiseGenerator* generator, int level, double x);
|
||||
double noiseGet1DTotal(NoiseGenerator* generator, double x);
|
||||
double noiseGet1DDetail(NoiseGenerator* generator, double x, double detail);
|
||||
double noiseGet2DLevel(NoiseGenerator* generator, int level, double x, double y);
|
||||
double noiseGet2DTotal(NoiseGenerator* generator, double x, double y);
|
||||
double noiseGet2DDetail(NoiseGenerator* generator, double x, double y, double detail);
|
||||
double noiseGet3DLevel(NoiseGenerator* generator, int level, double x, double y, double z);
|
||||
double noiseGet3DTotal(NoiseGenerator* generator, double x, double y, double z);
|
||||
double noiseGet3DDetail(NoiseGenerator* generator, double x, double y, double z, double detail);
|
||||
void noiseSetLevelSimple(NoiseGenerator* generator, int level, float scaling, float height);
|
||||
void noiseNormalizeHeight(NoiseGenerator* generator, float min_height, float max_height, int adjust_scaling);
|
||||
float noiseGet1DLevel(NoiseGenerator* generator, int level, float x);
|
||||
float noiseGet1DTotal(NoiseGenerator* generator, float x);
|
||||
float noiseGet1DDetail(NoiseGenerator* generator, float x, float detail);
|
||||
float noiseGet2DLevel(NoiseGenerator* generator, int level, float x, float y);
|
||||
float noiseGet2DTotal(NoiseGenerator* generator, float x, float y);
|
||||
float noiseGet2DDetail(NoiseGenerator* generator, float x, float y, float detail);
|
||||
float noiseGet3DLevel(NoiseGenerator* generator, int level, float x, float y, float z);
|
||||
float noiseGet3DTotal(NoiseGenerator* generator, float x, float y, float z);
|
||||
float noiseGet3DDetail(NoiseGenerator* generator, float x, float y, float z, float detail);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ struct PackStream
|
|||
#define unpack754_32(i) (unpack754((i), 32, 8))
|
||||
#define unpack754_64(i) (unpack754((i), 64, 11))
|
||||
|
||||
static uint64_t pack754(double f, unsigned bits, unsigned expbits)
|
||||
static uint64_t pack754(float f, unsigned bits, unsigned expbits)
|
||||
{
|
||||
double fnorm;
|
||||
float fnorm;
|
||||
int shift;
|
||||
long long sign, exp, significand;
|
||||
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
||||
|
@ -49,9 +49,9 @@ static uint64_t pack754(double f, unsigned bits, unsigned expbits)
|
|||
return (sign<<(bits-1)) | (exp<<(bits-expbits-1)) | significand;
|
||||
}
|
||||
|
||||
static double unpack754(uint64_t i, unsigned bits, unsigned expbits)
|
||||
static float unpack754(uint64_t i, unsigned bits, unsigned expbits)
|
||||
{
|
||||
double result;
|
||||
float result;
|
||||
long long shift;
|
||||
unsigned bias;
|
||||
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
|
||||
|
@ -107,15 +107,15 @@ void packCloseStream(PackStream* stream)
|
|||
free(stream);
|
||||
}
|
||||
|
||||
void packWriteDouble(PackStream* stream, double* value)
|
||||
void packWriteFloat(PackStream* stream, float* value)
|
||||
{
|
||||
uint64_t servalue;
|
||||
|
||||
servalue = pack754_64(*value);
|
||||
servalue = pack754_32(*value);
|
||||
fwrite(&servalue, sizeof(uint64_t), 1, stream->fd);
|
||||
}
|
||||
|
||||
void packReadDouble(PackStream* stream, double* value)
|
||||
void packReadFloat(PackStream* stream, float* value)
|
||||
{
|
||||
int read;
|
||||
uint64_t servalue;
|
||||
|
@ -123,7 +123,7 @@ void packReadDouble(PackStream* stream, double* value)
|
|||
read = fread(&servalue, sizeof(uint64_t), 1, stream->fd);
|
||||
assert(read == 1);
|
||||
|
||||
*value = unpack754_64(servalue);
|
||||
*value = unpack754_32(servalue);
|
||||
}
|
||||
|
||||
void packWriteInt(PackStream* stream, int* value)
|
||||
|
|
|
@ -11,8 +11,8 @@ PackStream* packReadFile(char* filepath);
|
|||
PackStream* packWriteFile(char* filepath);
|
||||
void packCloseStream(PackStream* stream);
|
||||
|
||||
void packWriteDouble(PackStream* stream, double* value);
|
||||
void packReadDouble(PackStream* stream, double* value);
|
||||
void packWriteFloat(PackStream* stream, float* value);
|
||||
void packReadFloat(PackStream* stream, float* value);
|
||||
void packWriteInt(PackStream* stream, int* value);
|
||||
void packReadInt(PackStream* stream, int* value);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ struct RenderArea
|
|||
|
||||
static void _callbackStart(int width, int height, Color background) {}
|
||||
static void _callbackDraw(int x, int y, Color col) {}
|
||||
static void _callbackUpdate(double progress) {}
|
||||
static void _callbackUpdate(float progress) {}
|
||||
|
||||
void renderInit()
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ void renderClear(RenderArea* area)
|
|||
|
||||
/*static int _sortRenderFragment(void const* a, void const* b)
|
||||
{
|
||||
double za, zb;
|
||||
float za, zb;
|
||||
za = ((RenderFragment*)a)->z;
|
||||
zb = ((RenderFragment*)b)->z;
|
||||
if (za > zb)
|
||||
|
@ -242,9 +242,9 @@ static inline Color _getFinalPixel(RenderArea* area, int x, int y)
|
|||
if (1 || pixel_data->dirty)
|
||||
{
|
||||
col = _getPixelColor(area->background_color, pixel_data);
|
||||
result.r += col.r / (double)(area->params.antialias * area->params.antialias);
|
||||
result.g += col.g / (double)(area->params.antialias * area->params.antialias);
|
||||
result.b += col.b / (double)(area->params.antialias * area->params.antialias);
|
||||
result.r += col.r / (float)(area->params.antialias * area->params.antialias);
|
||||
result.g += col.g / (float)(area->params.antialias * area->params.antialias);
|
||||
result.b += col.b / (float)(area->params.antialias * area->params.antialias);
|
||||
pixel_data->dirty = 0;
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ void renderAddFragment(RenderArea* area, RenderFragment* fragment)
|
|||
Array* pixel_data;
|
||||
int x = fragment->x;
|
||||
int y = fragment->y;
|
||||
double z = fragment->z;
|
||||
float z = fragment->z;
|
||||
|
||||
int i, dirty;
|
||||
int fragments_count;
|
||||
|
@ -371,7 +371,7 @@ void renderAddFragment(RenderArea* area, RenderFragment* fragment)
|
|||
}
|
||||
}
|
||||
|
||||
void renderPushFragment(RenderArea* area, int x, int y, double z, Vertex* vertex)
|
||||
void renderPushFragment(RenderArea* area, int x, int y, float z, Vertex* vertex)
|
||||
{
|
||||
RenderFragment fragment;
|
||||
|
||||
|
@ -399,7 +399,7 @@ static void __vertexGetDiff(Vertex* v1, Vertex* v2, Vertex* result)
|
|||
result->callback_data = v1->callback_data;
|
||||
}
|
||||
|
||||
static void __vertexInterpolate(Vertex* v1, Vertex* diff, double value, Vertex* result)
|
||||
static void __vertexInterpolate(Vertex* v1, Vertex* diff, float value, Vertex* result)
|
||||
{
|
||||
result->location.x = v1->location.x + diff->location.x * value;
|
||||
result->location.y = v1->location.y + diff->location.y * value;
|
||||
|
@ -453,7 +453,7 @@ static void __pushScanLinePoint(RenderArea* area, RenderFragment point)
|
|||
|
||||
static void __pushScanLineEdge(RenderArea* area, Vector3 v1, Vector3 v2, Vertex* vertex1, Vertex* vertex2)
|
||||
{
|
||||
double dx, dy, dz, fx;
|
||||
float dx, dy, dz, fx;
|
||||
Vertex diff;
|
||||
int startx = lround(v1.x);
|
||||
int endx = lround(v2.x);
|
||||
|
@ -501,7 +501,7 @@ static void __pushScanLineEdge(RenderArea* area, Vector3 v1, Vector3 v2, Vertex*
|
|||
__vertexGetDiff(vertex1, vertex2, &diff);
|
||||
for (curx = startx; curx <= endx; curx++)
|
||||
{
|
||||
fx = (double)curx + 0.5;
|
||||
fx = (float)curx + 0.5;
|
||||
if (fx < v1.x)
|
||||
{
|
||||
fx = v1.x;
|
||||
|
@ -537,7 +537,7 @@ static void __renderScanLines(RenderArea* area)
|
|||
{
|
||||
int x, starty, endy, cury;
|
||||
Vertex diff;
|
||||
double dy, dz, fy;
|
||||
float dy, dz, fy;
|
||||
RenderFragment up, down, current;
|
||||
|
||||
if (area->scanline_right > 0)
|
||||
|
@ -564,14 +564,14 @@ static void __renderScanLines(RenderArea* area)
|
|||
endy = area->params.height * area->params.antialias - 1;
|
||||
}
|
||||
|
||||
dy = (double)(up.y - down.y);
|
||||
dy = (float)(up.y - down.y);
|
||||
dz = up.z - down.z;
|
||||
__vertexGetDiff(&down.vertex, &up.vertex, &diff);
|
||||
|
||||
current.x = x;
|
||||
for (cury = starty; cury <= endy; cury++)
|
||||
{
|
||||
fy = (double)cury - down.y;
|
||||
fy = (float)cury - down.y;
|
||||
|
||||
current.y = cury;
|
||||
current.z = down.z + dz * fy / dy;
|
||||
|
@ -592,8 +592,8 @@ static void __renderScanLines(RenderArea* area)
|
|||
|
||||
void renderPushTriangle(RenderArea* area, Vertex* v1, Vertex* v2, Vertex* v3, Vector3 p1, Vector3 p2, Vector3 p3)
|
||||
{
|
||||
double limit_width = (double)(area->params.width * area->params.antialias - 1);
|
||||
double limit_height = (double)(area->params.height * area->params.antialias - 1);
|
||||
float limit_width = (float)(area->params.width * area->params.antialias - 1);
|
||||
float limit_height = (float)(area->params.height * area->params.antialias - 1);
|
||||
|
||||
/* Filter if outside screen */
|
||||
if (p1.z < 1.0 || p2.z < 1.0 || p3.z < 1.0 || (p1.x < 0.0 && p2.x < 0.0 && p3.x < 0.0) || (p1.y < 0.0 && p2.y < 0.0 && p3.y < 0.0) || (p1.x > limit_width && p2.x > limit_width && p3.x > limit_width) || (p1.y > limit_height && p2.y > limit_height && p3.y > limit_height))
|
||||
|
@ -761,7 +761,7 @@ void renderPostProcess(RenderArea* area, Renderer* renderer, int nbchunks)
|
|||
if (++loops >= 10)
|
||||
{
|
||||
mutexAcquire(area->lock);
|
||||
/*_progress = (double)_progress_pixels / (double)_pixel_count;*/
|
||||
/*_progress = (float)_progress_pixels / (float)_pixel_count;*/
|
||||
_processDirtyPixels(area);
|
||||
mutexRelease(area->lock);
|
||||
|
||||
|
@ -771,6 +771,7 @@ void renderPostProcess(RenderArea* area, Renderer* renderer, int nbchunks)
|
|||
|
||||
/*_progress = 1.0;*/
|
||||
_processDirtyPixels(area);
|
||||
area->callback_update(1.0);
|
||||
}
|
||||
|
||||
int renderSaveToFile(RenderArea* area, const char* path)
|
||||
|
|
|
@ -21,7 +21,7 @@ void renderClear(RenderArea* area);
|
|||
void renderUpdate(RenderArea* area);
|
||||
|
||||
void renderAddFragment(RenderArea* area, RenderFragment* fragment);
|
||||
void renderPushFragment(RenderArea* area, int x, int y, double z, Vertex* vertex);
|
||||
void renderPushFragment(RenderArea* area, int x, int y, float z, Vertex* vertex);
|
||||
void renderPushTriangle(RenderArea* area, Vertex* v1, Vertex* v2, Vertex* v3, Vector3 p1, Vector3 p2, Vector3 p3);
|
||||
|
||||
void renderPostProcess(RenderArea* area, Renderer* renderer, int nbchunks);
|
||||
|
|
|
@ -17,12 +17,12 @@ static void* _renderFirstPass(void* data)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int _addRenderProgress(Renderer* renderer, double progress)
|
||||
static int _addRenderProgress(Renderer* renderer, float progress)
|
||||
{
|
||||
return !renderer->render_interrupt;
|
||||
}
|
||||
|
||||
static double _getPrecision(Renderer* renderer, Vector3 location)
|
||||
static float _getPrecision(Renderer* renderer, Vector3 location)
|
||||
{
|
||||
return 0.001;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector
|
|||
return _RAYCASTING_NULL;
|
||||
}
|
||||
|
||||
static double _getTerrainHeight(Renderer* renderer, double x, double z)
|
||||
static float _getTerrainHeight(Renderer* renderer, float x, float z)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ static HeightInfo _getWaterHeightInfo(Renderer* renderer)
|
|||
return _WATER_HEIGHT_INFO;
|
||||
}
|
||||
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, double precision)
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, float precision)
|
||||
{
|
||||
return COLOR_TRANSPARENT;
|
||||
}
|
||||
|
|
|
@ -20,21 +20,21 @@ struct Renderer
|
|||
|
||||
/* Render related */
|
||||
RenderArea* render_area;
|
||||
double render_progress;
|
||||
float render_progress;
|
||||
int render_interrupt;
|
||||
int is_rendering;
|
||||
double (*getPrecision)(Renderer* renderer, Vector3 location);
|
||||
float (*getPrecision)(Renderer* renderer, Vector3 location);
|
||||
Vector3 (*projectPoint)(Renderer* renderer, Vector3 point);
|
||||
Vector3 (*unprojectPoint)(Renderer* renderer, Vector3 point);
|
||||
int (*addRenderProgress)(Renderer* renderer, double progress);
|
||||
int (*addRenderProgress)(Renderer* renderer, float progress);
|
||||
void (*pushTriangle)(Renderer* renderer, Vertex* v1, Vertex* v2, Vertex* v3);
|
||||
void (*pushQuad)(Renderer* renderer, Vertex* v1, Vertex* v2, Vertex* v3, Vertex* v4);
|
||||
|
||||
/* Scenery related */
|
||||
RayCastingResult (*rayWalking)(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds);
|
||||
double (*getTerrainHeight)(Renderer* renderer, double x, double z);
|
||||
float (*getTerrainHeight)(Renderer* renderer, float x, float z);
|
||||
HeightInfo (*getWaterHeightInfo)(Renderer* renderer);
|
||||
Color (*applyTextures)(Renderer* renderer, Vector3 location, double precision);
|
||||
Color (*applyTextures)(Renderer* renderer, Vector3 location, float precision);
|
||||
Color (*applyAtmosphere)(Renderer* renderer, Vector3 location, Color base);
|
||||
Color (*applyClouds)(Renderer* renderer, Color base, Vector3 start, Vector3 end);
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ static RayCastingResult _rayWalking(Renderer* renderer, Vector3 location, Vector
|
|||
return result;
|
||||
}
|
||||
|
||||
static double _getTerrainHeight(Renderer* renderer, double x, double z)
|
||||
static float _getTerrainHeight(Renderer* renderer, float x, float z)
|
||||
{
|
||||
return terrainGetHeight(&_terrain, x, z);
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ static HeightInfo _getWaterHeightInfo(Renderer* renderer)
|
|||
return waterGetHeightInfo(&_water);
|
||||
}
|
||||
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, double precision)
|
||||
static Color _applyTextures(Renderer* renderer, Vector3 location, float precision)
|
||||
{
|
||||
return texturesGetColor(&_textures, renderer, location.x, location.z, precision);
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ static Vector3 _unprojectPoint(Renderer* renderer, Vector3 point)
|
|||
return cameraUnproject(&renderer->render_camera, renderer, point);
|
||||
}
|
||||
|
||||
static double _getPrecision(Renderer* renderer, Vector3 location)
|
||||
static float _getPrecision(Renderer* renderer, Vector3 location)
|
||||
{
|
||||
Vector3 projected;
|
||||
|
||||
|
@ -330,7 +330,7 @@ static double _getPrecision(Renderer* renderer, Vector3 location)
|
|||
projected.x += 1.0;
|
||||
//projected.y += 1.0;
|
||||
|
||||
return v3Norm(v3Sub(cameraUnproject(&renderer->render_camera, renderer, projected), location)); // / (double)render_quality;
|
||||
return v3Norm(v3Sub(cameraUnproject(&renderer->render_camera, renderer, projected), location)); // / (float)render_quality;
|
||||
}
|
||||
|
||||
Renderer sceneryCreateStandardRenderer()
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef struct RenderFragment
|
|||
{
|
||||
int x;
|
||||
int y;
|
||||
double z;
|
||||
float z;
|
||||
Vertex vertex;
|
||||
} RenderFragment;
|
||||
|
||||
|
@ -53,13 +53,13 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
Color base;
|
||||
double reflection;
|
||||
double shininess;
|
||||
float reflection;
|
||||
float shininess;
|
||||
} SurfaceMaterial;
|
||||
|
||||
typedef void (*RenderCallbackStart)(int width, int height, Color background);
|
||||
typedef void (*RenderCallbackDraw)(int x, int y, Color col);
|
||||
typedef void (*RenderCallbackUpdate)(double progress);
|
||||
typedef void (*RenderCallbackUpdate)(float progress);
|
||||
|
||||
typedef struct RenderArea RenderArea;
|
||||
|
||||
|
@ -73,29 +73,29 @@ typedef RayCastingResult (*RayCastingFunction)(Vector3 start, Vector3 direction)
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double min_height;
|
||||
double max_height;
|
||||
double base_height;
|
||||
float min_height;
|
||||
float max_height;
|
||||
float base_height;
|
||||
} HeightInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector3 location;
|
||||
double yaw;
|
||||
double pitch;
|
||||
double roll;
|
||||
float yaw;
|
||||
float pitch;
|
||||
float roll;
|
||||
|
||||
Vector3 target;
|
||||
Vector3 forward;
|
||||
Vector3 right;
|
||||
Vector3 up;
|
||||
|
||||
double width;
|
||||
double height;
|
||||
double yfov;
|
||||
double xratio;
|
||||
double znear;
|
||||
double zfar;
|
||||
float width;
|
||||
float height;
|
||||
float yfov;
|
||||
float xratio;
|
||||
float znear;
|
||||
float zfar;
|
||||
|
||||
Matrix4 project;
|
||||
Matrix4 unproject;
|
||||
|
|
|
@ -23,28 +23,28 @@ void skyQuit()
|
|||
|
||||
void skySave(PackStream* stream, SkyDefinition* definition)
|
||||
{
|
||||
packWriteDouble(stream, &definition->daytime);
|
||||
packWriteFloat(stream, &definition->daytime);
|
||||
colorGradationSave(stream, definition->sun_color);
|
||||
packWriteDouble(stream, &definition->sun_radius);
|
||||
packWriteDouble(stream, &definition->sun_halo_size);
|
||||
packWriteFloat(stream, &definition->sun_radius);
|
||||
packWriteFloat(stream, &definition->sun_halo_size);
|
||||
curveSave(stream, definition->sun_halo_profile);
|
||||
colorGradationSave(stream, definition->zenith_color);
|
||||
colorGradationSave(stream, definition->haze_color);
|
||||
packWriteDouble(stream, &definition->haze_height);
|
||||
packWriteDouble(stream, &definition->haze_smoothing);
|
||||
packWriteFloat(stream, &definition->haze_height);
|
||||
packWriteFloat(stream, &definition->haze_smoothing);
|
||||
}
|
||||
|
||||
void skyLoad(PackStream* stream, SkyDefinition* definition)
|
||||
{
|
||||
packReadDouble(stream, &definition->daytime);
|
||||
packReadFloat(stream, &definition->daytime);
|
||||
colorGradationLoad(stream, definition->sun_color);
|
||||
packReadDouble(stream, &definition->sun_radius);
|
||||
packReadDouble(stream, &definition->sun_halo_size);
|
||||
packReadFloat(stream, &definition->sun_radius);
|
||||
packReadFloat(stream, &definition->sun_halo_size);
|
||||
curveLoad(stream, definition->sun_halo_profile);
|
||||
colorGradationLoad(stream, definition->zenith_color);
|
||||
colorGradationLoad(stream, definition->haze_color);
|
||||
packReadDouble(stream, &definition->haze_height);
|
||||
packReadDouble(stream, &definition->haze_smoothing);
|
||||
packReadFloat(stream, &definition->haze_height);
|
||||
packReadFloat(stream, &definition->haze_smoothing);
|
||||
|
||||
skyValidateDefinition(definition);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ void skyValidateDefinition(SkyDefinition* definition)
|
|||
|
||||
int skyGetLights(SkyDefinition* sky, LightDefinition* lights, int max_lights)
|
||||
{
|
||||
double sun_angle;
|
||||
float sun_angle;
|
||||
Vector3 sun_direction;
|
||||
int nblights = 0;
|
||||
|
||||
|
@ -152,7 +152,7 @@ int skyGetLights(SkyDefinition* sky, LightDefinition* lights, int max_lights)
|
|||
|
||||
Color skyGetColor(SkyDefinition* definition, Renderer* renderer, Vector3 eye, Vector3 look)
|
||||
{
|
||||
double dist;
|
||||
float dist;
|
||||
Vector3 sun_position;
|
||||
Color sun_color, sky_color;
|
||||
|
||||
|
@ -206,16 +206,16 @@ void skyRender(SkyDefinition* definition, Renderer* renderer)
|
|||
{
|
||||
int res_i, res_j;
|
||||
int i, j;
|
||||
double step_i, step_j;
|
||||
double current_i, current_j;
|
||||
float step_i, step_j;
|
||||
float current_i, current_j;
|
||||
Vertex vertex1, vertex2, vertex3, vertex4;
|
||||
Color col;
|
||||
Vector3 direction;
|
||||
|
||||
res_i = renderer->render_quality * 40;
|
||||
res_j = renderer->render_quality * 20;
|
||||
step_i = M_PI * 2.0 / (double)res_i;
|
||||
step_j = M_PI / (double)res_j;
|
||||
step_i = M_PI * 2.0 / (float)res_i;
|
||||
step_j = M_PI / (float)res_j;
|
||||
|
||||
col.r = 0.0;
|
||||
col.g = 0.0;
|
||||
|
@ -228,11 +228,11 @@ void skyRender(SkyDefinition* definition, Renderer* renderer)
|
|||
return;
|
||||
}
|
||||
|
||||
current_j = (double)(j - res_j / 2) * step_j;
|
||||
current_j = (float)(j - res_j / 2) * step_j;
|
||||
|
||||
for (i = 0; i < res_i; i++)
|
||||
{
|
||||
current_i = (double)i * step_i;
|
||||
current_i = (float)i * step_i;
|
||||
|
||||
direction.x = SPHERE_SIZE * cos(current_i) * cos(current_j);
|
||||
direction.y = SPHERE_SIZE * sin(current_j);
|
||||
|
@ -279,7 +279,7 @@ void skyRender(SkyDefinition* definition, Renderer* renderer)
|
|||
Vector3 skyGetSunDirection(SkyDefinition* definition)
|
||||
{
|
||||
Vector3 result;
|
||||
double sun_angle = (definition->daytime + 0.75) * M_PI * 2.0;
|
||||
float sun_angle = (definition->daytime + 0.75) * M_PI * 2.0;
|
||||
result.x = cos(sun_angle);
|
||||
result.y = sin(sun_angle);
|
||||
result.z = 0.0;
|
||||
|
|
|
@ -12,15 +12,15 @@ extern "C" {
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double daytime;
|
||||
float daytime;
|
||||
ColorGradation* sun_color;
|
||||
double sun_radius;
|
||||
double sun_halo_size;
|
||||
float sun_radius;
|
||||
float sun_halo_size;
|
||||
Curve* sun_halo_profile;
|
||||
ColorGradation* zenith_color;
|
||||
ColorGradation* haze_color;
|
||||
double haze_height;
|
||||
double haze_smoothing;
|
||||
float haze_height;
|
||||
float haze_smoothing;
|
||||
ColorGradation* _sky_gradation;
|
||||
} SkyDefinition;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ void terrainSave(PackStream* stream, TerrainDefinition* definition)
|
|||
int i;
|
||||
|
||||
noiseSaveGenerator(stream, definition->height_noise);
|
||||
packWriteDouble(stream, &definition->height_factor);
|
||||
packWriteDouble(stream, &definition->scaling);
|
||||
packWriteFloat(stream, &definition->height_factor);
|
||||
packWriteFloat(stream, &definition->scaling);
|
||||
|
||||
packWriteInt(stream, &definition->height_modifiers_count);
|
||||
for (i = 0; i < definition->height_modifiers_count; i++)
|
||||
|
@ -41,8 +41,8 @@ void terrainLoad(PackStream* stream, TerrainDefinition* definition)
|
|||
HeightModifier* modifier;
|
||||
|
||||
noiseLoadGenerator(stream, definition->height_noise);
|
||||
packReadDouble(stream, &definition->height_factor);
|
||||
packReadDouble(stream, &definition->scaling);
|
||||
packReadFloat(stream, &definition->height_factor);
|
||||
packReadFloat(stream, &definition->scaling);
|
||||
|
||||
while (definition->height_modifiers_count > 0)
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ void terrainDelModifier(TerrainDefinition* definition, int modifier_position)
|
|||
}
|
||||
}
|
||||
|
||||
static inline double _getHeight(TerrainDefinition* definition, double x, double z)
|
||||
static inline float _getHeight(TerrainDefinition* definition, float x, float z)
|
||||
{
|
||||
Vector3 location;
|
||||
int i;
|
||||
|
@ -156,7 +156,7 @@ static inline double _getHeight(TerrainDefinition* definition, double x, double
|
|||
return location.y;
|
||||
}
|
||||
|
||||
static inline double _getHeightDetail(TerrainDefinition* definition, double x, double z, double detail)
|
||||
static inline float _getHeightDetail(TerrainDefinition* definition, float x, float z, float detail)
|
||||
{
|
||||
Vector3 location;
|
||||
int i;
|
||||
|
@ -173,7 +173,7 @@ static inline double _getHeightDetail(TerrainDefinition* definition, double x, d
|
|||
return location.y;
|
||||
}
|
||||
|
||||
static inline Vector3 _getPoint(TerrainDefinition* definition, double x, double z)
|
||||
static inline Vector3 _getPoint(TerrainDefinition* definition, float x, float z)
|
||||
{
|
||||
Vector3 result;
|
||||
|
||||
|
@ -187,7 +187,7 @@ static inline Vector3 _getPoint(TerrainDefinition* definition, double x, double
|
|||
Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light)
|
||||
{
|
||||
Vector3 inc_vector;
|
||||
double inc_value, inc_base, inc_factor, height, diff, light_factor, smoothing, length;
|
||||
float inc_value, inc_base, inc_factor, height, diff, light_factor, smoothing, length;
|
||||
|
||||
direction_to_light = v3Normalize(direction_to_light);
|
||||
if (fabs(direction_to_light.x) < 0.0001 && fabs(direction_to_light.z) < 0.0001)
|
||||
|
@ -205,7 +205,7 @@ Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Colo
|
|||
light.b *= (0.05 + direction_to_light.y) / 0.05;
|
||||
}
|
||||
|
||||
inc_factor = (double)renderer->render_quality;
|
||||
inc_factor = (float)renderer->render_quality;
|
||||
inc_base = 1.0;
|
||||
inc_value = inc_base / inc_factor;
|
||||
smoothing = 0.03 * inc_factor;
|
||||
|
@ -253,7 +253,7 @@ Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Colo
|
|||
}
|
||||
}
|
||||
|
||||
static Color _getColor(TerrainDefinition* definition, Renderer* renderer, Vector3 point, double precision)
|
||||
static Color _getColor(TerrainDefinition* definition, Renderer* renderer, Vector3 point, float precision)
|
||||
{
|
||||
Color color;
|
||||
|
||||
|
@ -267,10 +267,10 @@ static Color _getColor(TerrainDefinition* definition, Renderer* renderer, Vector
|
|||
int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3 start, Vector3 direction, Vector3* hit_point, Color* hit_color)
|
||||
{
|
||||
Vector3 inc_vector;
|
||||
double inc_value, inc_base, inc_factor, height, diff, lastdiff, length;
|
||||
float inc_value, inc_base, inc_factor, height, diff, lastdiff, length;
|
||||
|
||||
direction = v3Normalize(direction);
|
||||
inc_factor = (double)renderer->render_quality;
|
||||
inc_factor = (float)renderer->render_quality;
|
||||
inc_base = 1.0;
|
||||
inc_value = inc_base / inc_factor;
|
||||
lastdiff = start.y - _getHeight(definition, start.x, start.z);
|
||||
|
@ -320,7 +320,7 @@ int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3
|
|||
static int _postProcessFragment(RenderFragment* fragment, Renderer* renderer, void* data)
|
||||
{
|
||||
Vector3 point;
|
||||
double precision;
|
||||
float precision;
|
||||
TerrainDefinition* definition;
|
||||
|
||||
definition = (TerrainDefinition*)data;
|
||||
|
@ -334,10 +334,10 @@ static int _postProcessFragment(RenderFragment* fragment, Renderer* renderer, vo
|
|||
return 1;
|
||||
}
|
||||
|
||||
static Vertex _getFirstPassVertex(TerrainDefinition* definition, double x, double z, double detail)
|
||||
static Vertex _getFirstPassVertex(TerrainDefinition* definition, float x, float z, float detail)
|
||||
{
|
||||
Vertex result;
|
||||
double value;
|
||||
float value;
|
||||
|
||||
result.location = _getPoint(definition, x, z);
|
||||
value = sin(x) * sin(x) * cos(z) * cos(z);
|
||||
|
@ -352,7 +352,7 @@ static Vertex _getFirstPassVertex(TerrainDefinition* definition, double x, doubl
|
|||
return result;
|
||||
}
|
||||
|
||||
static void _renderQuad(TerrainDefinition* definition, Renderer* renderer, double x, double z, double size, double water_height)
|
||||
static void _renderQuad(TerrainDefinition* definition, Renderer* renderer, float x, float z, float size, float water_height)
|
||||
{
|
||||
Vertex v1, v2, v3, v4;
|
||||
|
||||
|
@ -367,12 +367,12 @@ static void _renderQuad(TerrainDefinition* definition, Renderer* renderer, doubl
|
|||
}
|
||||
}
|
||||
|
||||
double terrainGetHeight(TerrainDefinition* definition, double x, double z)
|
||||
float terrainGetHeight(TerrainDefinition* definition, float x, float z)
|
||||
{
|
||||
return _getHeight(definition, x, z);
|
||||
}
|
||||
|
||||
double terrainGetHeightNormalized(TerrainDefinition* definition, double x, double z)
|
||||
float terrainGetHeightNormalized(TerrainDefinition* definition, float x, float z)
|
||||
{
|
||||
if (definition->_max_height == 0.0)
|
||||
{
|
||||
|
@ -384,7 +384,7 @@ double terrainGetHeightNormalized(TerrainDefinition* definition, double x, doubl
|
|||
}
|
||||
}
|
||||
|
||||
Color terrainGetColor(TerrainDefinition* definition, Renderer* renderer, double x, double z, double detail)
|
||||
Color terrainGetColor(TerrainDefinition* definition, Renderer* renderer, float x, float z, float detail)
|
||||
{
|
||||
Vector3 point = _getPoint(definition, x, z);
|
||||
return _getColor(definition, renderer, point, detail);
|
||||
|
@ -393,14 +393,14 @@ Color terrainGetColor(TerrainDefinition* definition, Renderer* renderer, double
|
|||
void terrainRender(TerrainDefinition* definition, Renderer* renderer)
|
||||
{
|
||||
int chunk_factor, chunk_count, i;
|
||||
double cx = renderer->camera_location.x;
|
||||
double cz = renderer->camera_location.z;
|
||||
double min_chunk_size, visible_chunk_size;
|
||||
double radius_int, radius_ext, chunk_size;
|
||||
double water_height;
|
||||
float cx = renderer->camera_location.x;
|
||||
float cz = renderer->camera_location.z;
|
||||
float min_chunk_size, visible_chunk_size;
|
||||
float radius_int, radius_ext, chunk_size;
|
||||
float water_height;
|
||||
|
||||
min_chunk_size = 0.1 / (double)renderer->render_quality;
|
||||
visible_chunk_size = 0.05 / (double)renderer->render_quality;
|
||||
min_chunk_size = 0.1 / (float)renderer->render_quality;
|
||||
visible_chunk_size = 0.05 / (float)renderer->render_quality;
|
||||
|
||||
chunk_factor = 1;
|
||||
chunk_count = 2;
|
||||
|
|
|
@ -16,12 +16,12 @@ extern "C" {
|
|||
typedef struct
|
||||
{
|
||||
NoiseGenerator* height_noise;
|
||||
double height_factor;
|
||||
double scaling;
|
||||
float height_factor;
|
||||
float scaling;
|
||||
int height_modifiers_count;
|
||||
HeightModifier* height_modifiers[TERRAIN_MAX_MODIFIERS];
|
||||
|
||||
double _max_height;
|
||||
float _max_height;
|
||||
} TerrainDefinition;
|
||||
|
||||
void terrainInit();
|
||||
|
@ -39,9 +39,9 @@ void terrainDelModifier(TerrainDefinition* definition, int modifier_position);
|
|||
|
||||
Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light);
|
||||
int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3 start, Vector3 direction, Vector3* hit_point, Color* hit_color);
|
||||
double terrainGetHeight(TerrainDefinition* definition, double x, double z);
|
||||
double terrainGetHeightNormalized(TerrainDefinition* definition, double x, double z);
|
||||
Color terrainGetColor(TerrainDefinition* definition, Renderer* renderer, double x, double z, double detail);
|
||||
float terrainGetHeight(TerrainDefinition* definition, float x, float z);
|
||||
float terrainGetHeightNormalized(TerrainDefinition* definition, float x, float z);
|
||||
Color terrainGetColor(TerrainDefinition* definition, Renderer* renderer, float x, float z, float detail);
|
||||
void terrainRender(TerrainDefinition* definition, Renderer* renderer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -16,7 +16,7 @@ static TextureLayerDefinition _NULL_LAYER;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double thickness;
|
||||
float thickness;
|
||||
Vector3 location;
|
||||
Vector3 normal;
|
||||
TextureLayerDefinition* definition;
|
||||
|
@ -41,12 +41,12 @@ void texturesSave(PackStream* stream, TexturesDefinition* definition)
|
|||
{
|
||||
zoneSave(stream, definition->textures[i].zone);
|
||||
noiseSaveGenerator(stream, definition->textures[i].bump_noise);
|
||||
packWriteDouble(stream, &definition->textures[i].bump_height);
|
||||
packWriteDouble(stream, &definition->textures[i].bump_scaling);
|
||||
packWriteFloat(stream, &definition->textures[i].bump_height);
|
||||
packWriteFloat(stream, &definition->textures[i].bump_scaling);
|
||||
materialSave(stream, &definition->textures[i].material);
|
||||
packWriteDouble(stream, &definition->textures[i].thickness);
|
||||
packWriteDouble(stream, &definition->textures[i].slope_range);
|
||||
packWriteDouble(stream, &definition->textures[i].thickness_transparency);
|
||||
packWriteFloat(stream, &definition->textures[i].thickness);
|
||||
packWriteFloat(stream, &definition->textures[i].slope_range);
|
||||
packWriteFloat(stream, &definition->textures[i].thickness_transparency);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,12 +67,12 @@ void texturesLoad(PackStream* stream, TexturesDefinition* definition)
|
|||
|
||||
zoneLoad(stream, layer->zone);
|
||||
noiseLoadGenerator(stream, layer->bump_noise);
|
||||
packReadDouble(stream, &layer->bump_height);
|
||||
packReadDouble(stream, &layer->bump_scaling);
|
||||
packReadFloat(stream, &layer->bump_height);
|
||||
packReadFloat(stream, &layer->bump_scaling);
|
||||
materialLoad(stream, &layer->material);
|
||||
packReadDouble(stream, &definition->textures[i].thickness);
|
||||
packReadDouble(stream, &definition->textures[i].slope_range);
|
||||
packReadDouble(stream, &definition->textures[i].thickness_transparency);
|
||||
packReadFloat(stream, &definition->textures[i].thickness);
|
||||
packReadFloat(stream, &definition->textures[i].slope_range);
|
||||
packReadFloat(stream, &definition->textures[i].thickness_transparency);
|
||||
}
|
||||
|
||||
texturesValidateDefinition(definition);
|
||||
|
@ -236,7 +236,7 @@ static inline Vector3 _getNormal2(Vector3 center, Vector3 east, Vector3 south)
|
|||
return v3Normalize(v3Cross(v3Sub(south, center), v3Sub(east, center)));
|
||||
}
|
||||
|
||||
static inline TextureResult _getTerrainResult(Renderer* renderer, double x, double z, double detail)
|
||||
static inline TextureResult _getTerrainResult(Renderer* renderer, float x, float z, float detail)
|
||||
{
|
||||
TextureResult result;
|
||||
Vector3 center, north, east, south, west;
|
||||
|
@ -279,10 +279,10 @@ static inline TextureResult _getTerrainResult(Renderer* renderer, double x, doub
|
|||
return result;
|
||||
}
|
||||
|
||||
static inline void _getLayerThickness(TextureLayerDefinition* definition, Renderer* renderer, double x, double z, TextureResult* result)
|
||||
static inline void _getLayerThickness(TextureLayerDefinition* definition, Renderer* renderer, float x, float z, TextureResult* result)
|
||||
{
|
||||
TextureResult base;
|
||||
double coverage;
|
||||
float coverage;
|
||||
|
||||
base = _getTerrainResult(renderer, x, z, definition->slope_range);
|
||||
coverage = zoneGetValue(definition->zone, base.location, base.normal);
|
||||
|
@ -300,7 +300,7 @@ static inline void _getLayerThickness(TextureLayerDefinition* definition, Render
|
|||
}
|
||||
}
|
||||
|
||||
static inline TextureResult _getLayerResult(TextureLayerDefinition* definition, Renderer* renderer, double x, double z, double detail)
|
||||
static inline TextureResult _getLayerResult(TextureLayerDefinition* definition, Renderer* renderer, float x, float z, float detail)
|
||||
{
|
||||
TextureResult result_center, result_north, result_east, result_south, result_west;
|
||||
|
||||
|
@ -330,7 +330,7 @@ static int _cmpResults(const void* result1, const void* result2)
|
|||
return ((TextureResult*)result1)->thickness > ((TextureResult*)result2)->thickness;
|
||||
}
|
||||
|
||||
double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail)
|
||||
float texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, float detail)
|
||||
{
|
||||
TextureResult base = _getTerrainResult(renderer, location.x, location.z, definition->slope_range);
|
||||
return zoneGetValue(definition->zone, base.location, base.normal);
|
||||
|
@ -341,7 +341,7 @@ static inline Color _getLayerColor(Renderer* renderer, TextureResult result, Lig
|
|||
return renderer->applyLightStatus(renderer, light, result.location, result.normal, result.definition->material);
|
||||
}
|
||||
|
||||
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail)
|
||||
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, float detail)
|
||||
{
|
||||
LightStatus light;
|
||||
TextureResult result = _getLayerResult(definition, renderer, location.x, location.z, detail);
|
||||
|
@ -349,11 +349,11 @@ Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* render
|
|||
return _getLayerColor(renderer, result, &light);
|
||||
}
|
||||
|
||||
Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, double x, double z, double detail)
|
||||
Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, float x, float z, float detail)
|
||||
{
|
||||
TextureResult results[TEXTURES_MAX_LAYERS + 1];
|
||||
Color result, color;
|
||||
double thickness, last_height;
|
||||
float thickness, last_height;
|
||||
int i, start;
|
||||
|
||||
detail *= 0.1;
|
||||
|
|
|
@ -17,12 +17,12 @@ typedef struct
|
|||
{
|
||||
Zone* zone;
|
||||
NoiseGenerator* bump_noise;
|
||||
double bump_scaling;
|
||||
double bump_height;
|
||||
float bump_scaling;
|
||||
float bump_height;
|
||||
SurfaceMaterial material;
|
||||
double thickness;
|
||||
double slope_range;
|
||||
double thickness_transparency;
|
||||
float thickness;
|
||||
float slope_range;
|
||||
float thickness_transparency;
|
||||
} TextureLayerDefinition;
|
||||
|
||||
typedef struct
|
||||
|
@ -51,9 +51,9 @@ TextureLayerDefinition* texturesGetLayer(TexturesDefinition* definition, int lay
|
|||
int texturesAddLayer(TexturesDefinition* definition);
|
||||
void texturesDeleteLayer(TexturesDefinition* definition, int layer);
|
||||
|
||||
double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);
|
||||
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);
|
||||
Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, double x, double z, double detail);
|
||||
float texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, float detail);
|
||||
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, float detail);
|
||||
Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, float x, float z, float detail);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
#include "color.h"
|
||||
#include "euclid.h"
|
||||
|
||||
double toolsRandom()
|
||||
float toolsRandom()
|
||||
{
|
||||
return (double)rand() / (double)RAND_MAX;
|
||||
return (float)rand() / (float)RAND_MAX;
|
||||
}
|
||||
|
||||
static inline double __cubicInterpolate(double p[4], double x)
|
||||
static inline float __cubicInterpolate(float p[4], float x)
|
||||
{
|
||||
return p[1] + 0.5 * x * (p[2] - p[0] + x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] + x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
|
||||
}
|
||||
|
||||
double toolsBicubicInterpolate(double stencil[16], double x, double y)
|
||||
float toolsBicubicInterpolate(float stencil[16], float x, float y)
|
||||
{
|
||||
double buf_cubic_y[4];
|
||||
float buf_cubic_y[4];
|
||||
|
||||
buf_cubic_y[0] = __cubicInterpolate(stencil, x);
|
||||
buf_cubic_y[1] = __cubicInterpolate(stencil + 4, x);
|
||||
|
@ -30,12 +30,12 @@ double toolsBicubicInterpolate(double stencil[16], double x, double y)
|
|||
return __cubicInterpolate(buf_cubic_y, y);
|
||||
}
|
||||
|
||||
void toolsFloat2DMapCopy(double* src, double* dest, int src_xstart, int src_ystart, int dest_xstart, int dest_ystart, int xsize, int ysize, int src_xstep, int src_ystep, int dest_xstep, int dest_ystep)
|
||||
void toolsFloat2DMapCopy(float* src, float* dest, int src_xstart, int src_ystart, int dest_xstart, int dest_ystart, int xsize, int ysize, int src_xstep, int src_ystep, int dest_xstep, int dest_ystep)
|
||||
{
|
||||
/* TODO Optimize with memcpy if src_xstep == dest_xstep == 1 */
|
||||
int x, y;
|
||||
double* src_row;
|
||||
double* dest_row;
|
||||
float* src_row;
|
||||
float* dest_row;
|
||||
src += src_ystart * src_ystep + src_xstart * src_xstep;
|
||||
dest += dest_ystart * dest_ystep + dest_xstart * dest_xstep;
|
||||
for (y = 0; y < ysize; y++)
|
||||
|
@ -60,23 +60,23 @@ Vector3 toolsGetNormalFromTriangle(Vector3 center, Vector3 bottom, Vector3 right
|
|||
return v3Normalize(v3Cross(dz, dx));
|
||||
}
|
||||
|
||||
double toolsGetDistance2D(double x1, double y1, double x2, double y2)
|
||||
float toolsGetDistance2D(float x1, float y1, float x2, float y2)
|
||||
{
|
||||
double dx = x2 - x1;
|
||||
double dy = y2 - y1;
|
||||
float dx = x2 - x1;
|
||||
float dy = y2 - y1;
|
||||
return sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
void materialSave(PackStream* stream, SurfaceMaterial* material)
|
||||
{
|
||||
colorSave(stream, &material->base);
|
||||
packWriteDouble(stream, &material->reflection);
|
||||
packWriteDouble(stream, &material->shininess);
|
||||
packWriteFloat(stream, &material->reflection);
|
||||
packWriteFloat(stream, &material->shininess);
|
||||
}
|
||||
|
||||
void materialLoad(PackStream* stream, SurfaceMaterial* material)
|
||||
{
|
||||
colorLoad(stream, &material->base);
|
||||
packReadDouble(stream, &material->reflection);
|
||||
packReadDouble(stream, &material->shininess);
|
||||
packReadFloat(stream, &material->reflection);
|
||||
packReadFloat(stream, &material->shininess);
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
double toolsRandom();
|
||||
double toolsBicubicInterpolate(double stencil[16], double x, double y);
|
||||
void toolsFloat2DMapCopy(double* src, double* dest, int src_xstart, int src_ystart, int dest_xstart, int dest_ystart, int xsize, int ysize, int src_xstep, int src_ystep, int dest_xstep, int dest_ystep);
|
||||
float toolsRandom();
|
||||
float toolsBicubicInterpolate(float stencil[16], float x, float y);
|
||||
void toolsFloat2DMapCopy(float* src, float* dest, int src_xstart, int src_ystart, int dest_xstart, int dest_ystart, int xsize, int ysize, int src_xstep, int src_ystep, int dest_xstep, int dest_ystep);
|
||||
Vector3 toolsGetNormalFromTriangle(Vector3 center, Vector3 bottom, Vector3 right);
|
||||
double toolsGetDistance2D(double x1, double y1, double x2, double y2);
|
||||
float toolsGetDistance2D(float x1, float y1, float x2, float y2);
|
||||
void materialSave(PackStream* stream, SurfaceMaterial* material);
|
||||
void materialLoad(PackStream* stream, SurfaceMaterial* material);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
typedef struct
|
||||
{
|
||||
Zone* zone;
|
||||
double max_height;
|
||||
float max_height;
|
||||
} VegetationLayerDefinition;
|
||||
|
||||
typedef struct VegetationDefinition VegetationDefinition;
|
||||
|
@ -39,7 +39,7 @@ int vegetationSetLayer(VegetationDefinition* definition, int position, Vegetatio
|
|||
int vegetationAddLayer(VegetationDefinition* definition);
|
||||
void vegetationDeleteLayer(VegetationDefinition* definition, int layer);
|
||||
|
||||
/*double vegetationGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail);*/
|
||||
/*float vegetationGetLayerCoverage(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, float detail);*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -20,30 +20,30 @@ void waterQuit()
|
|||
|
||||
void waterSave(PackStream* stream, WaterDefinition* definition)
|
||||
{
|
||||
packWriteDouble(stream, &definition->height);
|
||||
packWriteFloat(stream, &definition->height);
|
||||
materialSave(stream, &definition->material);
|
||||
colorSave(stream, &definition->depth_color);
|
||||
packWriteDouble(stream, &definition->transparency_depth);
|
||||
packWriteDouble(stream, &definition->transparency);
|
||||
packWriteDouble(stream, &definition->reflection);
|
||||
packWriteDouble(stream, &definition->lighting_depth);
|
||||
packWriteFloat(stream, &definition->transparency_depth);
|
||||
packWriteFloat(stream, &definition->transparency);
|
||||
packWriteFloat(stream, &definition->reflection);
|
||||
packWriteFloat(stream, &definition->lighting_depth);
|
||||
noiseSaveGenerator(stream, definition->waves_noise);
|
||||
packWriteDouble(stream, &definition->waves_noise_height);
|
||||
packWriteDouble(stream, &definition->waves_noise_scale);
|
||||
packWriteFloat(stream, &definition->waves_noise_height);
|
||||
packWriteFloat(stream, &definition->waves_noise_scale);
|
||||
}
|
||||
|
||||
void waterLoad(PackStream* stream, WaterDefinition* definition)
|
||||
{
|
||||
packReadDouble(stream, &definition->height);
|
||||
packReadFloat(stream, &definition->height);
|
||||
materialLoad(stream, &definition->material);
|
||||
colorLoad(stream, &definition->depth_color);
|
||||
packReadDouble(stream, &definition->transparency_depth);
|
||||
packReadDouble(stream, &definition->transparency);
|
||||
packReadDouble(stream, &definition->reflection);
|
||||
packReadDouble(stream, &definition->lighting_depth);
|
||||
packReadFloat(stream, &definition->transparency_depth);
|
||||
packReadFloat(stream, &definition->transparency);
|
||||
packReadFloat(stream, &definition->reflection);
|
||||
packReadFloat(stream, &definition->lighting_depth);
|
||||
noiseLoadGenerator(stream, definition->waves_noise);
|
||||
packReadDouble(stream, &definition->waves_noise_height);
|
||||
packReadDouble(stream, &definition->waves_noise_scale);
|
||||
packReadFloat(stream, &definition->waves_noise_height);
|
||||
packReadFloat(stream, &definition->waves_noise_scale);
|
||||
|
||||
waterValidateDefinition(definition);
|
||||
}
|
||||
|
@ -87,15 +87,15 @@ void waterValidateDefinition(WaterDefinition* definition)
|
|||
{
|
||||
}
|
||||
|
||||
static inline double _getHeight(WaterDefinition* definition, double x, double z, double detail)
|
||||
static inline float _getHeight(WaterDefinition* definition, float x, float z, float detail)
|
||||
{
|
||||
return definition->height + noiseGet2DDetail(definition->waves_noise, x / definition->waves_noise_scale, z / definition->waves_noise_scale, detail) * definition->waves_noise_height;
|
||||
}
|
||||
|
||||
static inline Vector3 _getNormal(WaterDefinition* definition, Vector3 base, double detail)
|
||||
static inline Vector3 _getNormal(WaterDefinition* definition, Vector3 base, float detail)
|
||||
{
|
||||
Vector3 back, right;
|
||||
double x, z;
|
||||
float x, z;
|
||||
|
||||
x = base.x;
|
||||
z = base.z;
|
||||
|
@ -115,7 +115,7 @@ static inline Vector3 _getNormal(WaterDefinition* definition, Vector3 base, doub
|
|||
|
||||
static inline Vector3 _reflectRay(Vector3 incoming, Vector3 normal)
|
||||
{
|
||||
double c;
|
||||
float c;
|
||||
|
||||
c = v3Dot(normal, v3Scale(incoming, -1.0));
|
||||
return v3Add(incoming, v3Scale(normal, 2.0 * c));
|
||||
|
@ -123,7 +123,7 @@ static inline Vector3 _reflectRay(Vector3 incoming, Vector3 normal)
|
|||
|
||||
static inline Vector3 _refractRay(Vector3 incoming, Vector3 normal)
|
||||
{
|
||||
double c1, c2, f;
|
||||
float c1, c2, f;
|
||||
|
||||
f = 1.0 / 1.33;
|
||||
c1 = v3Dot(normal, v3Scale(incoming, -1.0));
|
||||
|
@ -151,7 +151,7 @@ HeightInfo waterGetHeightInfo(WaterDefinition* definition)
|
|||
|
||||
Color waterLightFilter(WaterDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light)
|
||||
{
|
||||
double factor;
|
||||
float factor;
|
||||
|
||||
if (location.y < definition->height)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
|||
Color color;
|
||||
LightStatus light;
|
||||
SurfaceMaterial material;
|
||||
double detail, depth;
|
||||
float detail, depth;
|
||||
|
||||
detail = renderer->getPrecision(renderer, location);
|
||||
|
||||
|
@ -243,10 +243,10 @@ static int _postProcessFragment(RenderFragment* fragment, Renderer* renderer, vo
|
|||
return 1;
|
||||
}
|
||||
|
||||
static Vertex _getFirstPassVertex(WaterDefinition* definition, double x, double z, double precision)
|
||||
static Vertex _getFirstPassVertex(WaterDefinition* definition, float x, float z, float precision)
|
||||
{
|
||||
Vertex result;
|
||||
double value;
|
||||
float value;
|
||||
|
||||
result.location.x = x;
|
||||
result.location.y = _getHeight(definition, x, z, 0.0);
|
||||
|
@ -263,7 +263,7 @@ static Vertex _getFirstPassVertex(WaterDefinition* definition, double x, double
|
|||
return result;
|
||||
}
|
||||
|
||||
static void _renderQuad(WaterDefinition* definition, Renderer* renderer, double x, double z, double size)
|
||||
static void _renderQuad(WaterDefinition* definition, Renderer* renderer, float x, float z, float size)
|
||||
{
|
||||
Vertex v1, v2, v3, v4;
|
||||
|
||||
|
@ -277,11 +277,11 @@ static void _renderQuad(WaterDefinition* definition, Renderer* renderer, double
|
|||
void waterRender(WaterDefinition* definition, Renderer* renderer)
|
||||
{
|
||||
int chunk_factor, chunk_count, i;
|
||||
double cx = renderer->camera_location.x;
|
||||
double cz = renderer->camera_location.z;
|
||||
double radius_int, radius_ext, base_chunk_size, chunk_size;
|
||||
float cx = renderer->camera_location.x;
|
||||
float cz = renderer->camera_location.z;
|
||||
float radius_int, radius_ext, base_chunk_size, chunk_size;
|
||||
|
||||
base_chunk_size = 2.0 / (double)renderer->render_quality;
|
||||
base_chunk_size = 2.0 / (float)renderer->render_quality;
|
||||
|
||||
chunk_factor = 1;
|
||||
chunk_count = 2;
|
||||
|
@ -304,7 +304,7 @@ void waterRender(WaterDefinition* definition, Renderer* renderer)
|
|||
_renderQuad(definition, renderer, cx - radius_ext, cz + radius_int - chunk_size * i, chunk_size);
|
||||
}
|
||||
|
||||
if (radius_int > 20.0 && chunk_count % 64 == 0 && (double)chunk_factor < radius_int / 20.0)
|
||||
if (radius_int > 20.0 && chunk_count % 64 == 0 && (float)chunk_factor < radius_int / 20.0)
|
||||
{
|
||||
chunk_count /= 2;
|
||||
chunk_factor *= 2;
|
||||
|
|
|
@ -13,16 +13,16 @@ extern "C" {
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double height;
|
||||
double transparency;
|
||||
double reflection;
|
||||
float height;
|
||||
float transparency;
|
||||
float reflection;
|
||||
SurfaceMaterial material;
|
||||
Color depth_color;
|
||||
double transparency_depth;
|
||||
double lighting_depth;
|
||||
float transparency_depth;
|
||||
float lighting_depth;
|
||||
NoiseGenerator* waves_noise;
|
||||
double waves_noise_height;
|
||||
double waves_noise_scale;
|
||||
float waves_noise_height;
|
||||
float waves_noise_scale;
|
||||
} WaterDefinition;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double value;
|
||||
double centerx;
|
||||
double centerz;
|
||||
double softradius;
|
||||
double hardradius;
|
||||
float value;
|
||||
float centerx;
|
||||
float centerz;
|
||||
float softradius;
|
||||
float hardradius;
|
||||
} Circle;
|
||||
|
||||
struct Zone {
|
||||
|
@ -55,41 +55,41 @@ void zoneSave(PackStream* stream, Zone* zone)
|
|||
packWriteInt(stream, &zone->height_ranges_count);
|
||||
for (i = 0; i < zone->height_ranges_count; i++)
|
||||
{
|
||||
packWriteDouble(stream, &zone->height_ranges[i].value);
|
||||
packWriteDouble(stream, &zone->height_ranges[i].hardmin);
|
||||
packWriteDouble(stream, &zone->height_ranges[i].softmin);
|
||||
packWriteDouble(stream, &zone->height_ranges[i].softmax);
|
||||
packWriteDouble(stream, &zone->height_ranges[i].hardmax);
|
||||
packWriteFloat(stream, &zone->height_ranges[i].value);
|
||||
packWriteFloat(stream, &zone->height_ranges[i].hardmin);
|
||||
packWriteFloat(stream, &zone->height_ranges[i].softmin);
|
||||
packWriteFloat(stream, &zone->height_ranges[i].softmax);
|
||||
packWriteFloat(stream, &zone->height_ranges[i].hardmax);
|
||||
}
|
||||
|
||||
packWriteInt(stream, &zone->slope_ranges_count);
|
||||
for (i = 0; i < zone->slope_ranges_count; i++)
|
||||
{
|
||||
packWriteDouble(stream, &zone->slope_ranges[i].value);
|
||||
packWriteDouble(stream, &zone->slope_ranges[i].hardmin);
|
||||
packWriteDouble(stream, &zone->slope_ranges[i].softmin);
|
||||
packWriteDouble(stream, &zone->slope_ranges[i].softmax);
|
||||
packWriteDouble(stream, &zone->slope_ranges[i].hardmax);
|
||||
packWriteFloat(stream, &zone->slope_ranges[i].value);
|
||||
packWriteFloat(stream, &zone->slope_ranges[i].hardmin);
|
||||
packWriteFloat(stream, &zone->slope_ranges[i].softmin);
|
||||
packWriteFloat(stream, &zone->slope_ranges[i].softmax);
|
||||
packWriteFloat(stream, &zone->slope_ranges[i].hardmax);
|
||||
}
|
||||
|
||||
packWriteInt(stream, &zone->circles_included_count);
|
||||
for (i = 0; i < zone->circles_included_count; i++)
|
||||
{
|
||||
packWriteDouble(stream, &zone->circles_included[i].value);
|
||||
packWriteDouble(stream, &zone->circles_included[i].centerx);
|
||||
packWriteDouble(stream, &zone->circles_included[i].centerz);
|
||||
packWriteDouble(stream, &zone->circles_included[i].softradius);
|
||||
packWriteDouble(stream, &zone->circles_included[i].hardradius);
|
||||
packWriteFloat(stream, &zone->circles_included[i].value);
|
||||
packWriteFloat(stream, &zone->circles_included[i].centerx);
|
||||
packWriteFloat(stream, &zone->circles_included[i].centerz);
|
||||
packWriteFloat(stream, &zone->circles_included[i].softradius);
|
||||
packWriteFloat(stream, &zone->circles_included[i].hardradius);
|
||||
}
|
||||
|
||||
packWriteInt(stream, &zone->circles_excluded_count);
|
||||
for (i = 0; i < zone->circles_excluded_count; i++)
|
||||
{
|
||||
packWriteDouble(stream, &zone->circles_excluded[i].value);
|
||||
packWriteDouble(stream, &zone->circles_excluded[i].centerx);
|
||||
packWriteDouble(stream, &zone->circles_excluded[i].centerz);
|
||||
packWriteDouble(stream, &zone->circles_excluded[i].softradius);
|
||||
packWriteDouble(stream, &zone->circles_excluded[i].hardradius);
|
||||
packWriteFloat(stream, &zone->circles_excluded[i].value);
|
||||
packWriteFloat(stream, &zone->circles_excluded[i].centerx);
|
||||
packWriteFloat(stream, &zone->circles_excluded[i].centerz);
|
||||
packWriteFloat(stream, &zone->circles_excluded[i].softradius);
|
||||
packWriteFloat(stream, &zone->circles_excluded[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,41 +100,41 @@ void zoneLoad(PackStream* stream, Zone* zone)
|
|||
packReadInt(stream, &zone->height_ranges_count);
|
||||
for (i = 0; i < zone->height_ranges_count; i++)
|
||||
{
|
||||
packReadDouble(stream, &zone->height_ranges[i].value);
|
||||
packReadDouble(stream, &zone->height_ranges[i].hardmin);
|
||||
packReadDouble(stream, &zone->height_ranges[i].softmin);
|
||||
packReadDouble(stream, &zone->height_ranges[i].softmax);
|
||||
packReadDouble(stream, &zone->height_ranges[i].hardmax);
|
||||
packReadFloat(stream, &zone->height_ranges[i].value);
|
||||
packReadFloat(stream, &zone->height_ranges[i].hardmin);
|
||||
packReadFloat(stream, &zone->height_ranges[i].softmin);
|
||||
packReadFloat(stream, &zone->height_ranges[i].softmax);
|
||||
packReadFloat(stream, &zone->height_ranges[i].hardmax);
|
||||
}
|
||||
|
||||
packReadInt(stream, &zone->slope_ranges_count);
|
||||
for (i = 0; i < zone->slope_ranges_count; i++)
|
||||
{
|
||||
packReadDouble(stream, &zone->slope_ranges[i].value);
|
||||
packReadDouble(stream, &zone->slope_ranges[i].hardmin);
|
||||
packReadDouble(stream, &zone->slope_ranges[i].softmin);
|
||||
packReadDouble(stream, &zone->slope_ranges[i].softmax);
|
||||
packReadDouble(stream, &zone->slope_ranges[i].hardmax);
|
||||
packReadFloat(stream, &zone->slope_ranges[i].value);
|
||||
packReadFloat(stream, &zone->slope_ranges[i].hardmin);
|
||||
packReadFloat(stream, &zone->slope_ranges[i].softmin);
|
||||
packReadFloat(stream, &zone->slope_ranges[i].softmax);
|
||||
packReadFloat(stream, &zone->slope_ranges[i].hardmax);
|
||||
}
|
||||
|
||||
packReadInt(stream, &zone->circles_included_count);
|
||||
for (i = 0; i < zone->circles_included_count; i++)
|
||||
{
|
||||
packReadDouble(stream, &zone->circles_included[i].value);
|
||||
packReadDouble(stream, &zone->circles_included[i].centerx);
|
||||
packReadDouble(stream, &zone->circles_included[i].centerz);
|
||||
packReadDouble(stream, &zone->circles_included[i].softradius);
|
||||
packReadDouble(stream, &zone->circles_included[i].hardradius);
|
||||
packReadFloat(stream, &zone->circles_included[i].value);
|
||||
packReadFloat(stream, &zone->circles_included[i].centerx);
|
||||
packReadFloat(stream, &zone->circles_included[i].centerz);
|
||||
packReadFloat(stream, &zone->circles_included[i].softradius);
|
||||
packReadFloat(stream, &zone->circles_included[i].hardradius);
|
||||
}
|
||||
|
||||
packReadInt(stream, &zone->circles_excluded_count);
|
||||
for (i = 0; i < zone->circles_excluded_count; i++)
|
||||
{
|
||||
packReadDouble(stream, &zone->circles_excluded[i].value);
|
||||
packReadDouble(stream, &zone->circles_excluded[i].centerx);
|
||||
packReadDouble(stream, &zone->circles_excluded[i].centerz);
|
||||
packReadDouble(stream, &zone->circles_excluded[i].softradius);
|
||||
packReadDouble(stream, &zone->circles_excluded[i].hardradius);
|
||||
packReadFloat(stream, &zone->circles_excluded[i].value);
|
||||
packReadFloat(stream, &zone->circles_excluded[i].centerx);
|
||||
packReadFloat(stream, &zone->circles_excluded[i].centerz);
|
||||
packReadFloat(stream, &zone->circles_excluded[i].softradius);
|
||||
packReadFloat(stream, &zone->circles_excluded[i].hardradius);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ void zoneCopy(Zone* source, Zone* destination)
|
|||
*destination = *source;
|
||||
}
|
||||
|
||||
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius)
|
||||
void zoneIncludeCircleArea(Zone* zone, float value, float centerx, float centerz, float softradius, float hardradius)
|
||||
{
|
||||
Circle circle = {value, centerx, centerz, softradius, hardradius};
|
||||
|
||||
|
@ -153,7 +153,7 @@ void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double cent
|
|||
}
|
||||
}
|
||||
|
||||
void zoneExcludeCircleArea(Zone* zone, double centerx, double centerz, double softradius, double hardradius)
|
||||
void zoneExcludeCircleArea(Zone* zone, float centerx, float centerz, float softradius, float hardradius)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ int zoneSetHeightRange(Zone* zone, int position, ZoneRangeCondition* range)
|
|||
}
|
||||
}
|
||||
|
||||
int zoneAddHeightRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax)
|
||||
int zoneAddHeightRangeQuick(Zone* zone, float value, float hardmin, float softmin, float softmax, float hardmax)
|
||||
{
|
||||
ZoneRangeCondition range = {value, hardmin, softmin, softmax, hardmax};
|
||||
int position;
|
||||
|
@ -267,7 +267,7 @@ int zoneSetSlopeRange(Zone* zone, int position, ZoneRangeCondition* range)
|
|||
}
|
||||
}
|
||||
|
||||
int zoneAddSlopeRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax)
|
||||
int zoneAddSlopeRangeQuick(Zone* zone, float value, float hardmin, float softmin, float softmax, float hardmax)
|
||||
{
|
||||
ZoneRangeCondition range = {value, hardmin, softmin, softmax, hardmax};
|
||||
int position;
|
||||
|
@ -280,7 +280,7 @@ int zoneAddSlopeRangeQuick(Zone* zone, double value, double hardmin, double soft
|
|||
return position;
|
||||
}
|
||||
|
||||
static inline double _getRangeInfluence(ZoneRangeCondition range, double position)
|
||||
static inline float _getRangeInfluence(ZoneRangeCondition range, float position)
|
||||
{
|
||||
if (position >= range.hardmin && position <= range.hardmax)
|
||||
{
|
||||
|
@ -303,9 +303,9 @@ static inline double _getRangeInfluence(ZoneRangeCondition range, double positio
|
|||
}
|
||||
}
|
||||
|
||||
static inline double _getCircleInfluence(Circle circle, Vector3 position)
|
||||
static inline float _getCircleInfluence(Circle circle, Vector3 position)
|
||||
{
|
||||
double radius, dx, dz;
|
||||
float radius, dx, dz;
|
||||
|
||||
dx = position.x - circle.centerx;
|
||||
dz = position.z - circle.centerz;
|
||||
|
@ -325,10 +325,10 @@ static inline double _getCircleInfluence(Circle circle, Vector3 position)
|
|||
}
|
||||
}
|
||||
|
||||
double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal)
|
||||
float zoneGetValue(Zone* zone, Vector3 location, Vector3 normal)
|
||||
{
|
||||
int i;
|
||||
double value, value_height, value_steepness, value_circle;
|
||||
float value, value_height, value_steepness, value_circle;
|
||||
|
||||
if (zone->circles_included_count > 0)
|
||||
{
|
||||
|
|
|
@ -12,11 +12,11 @@ typedef struct Zone Zone;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
double value;
|
||||
double hardmin;
|
||||
double softmin;
|
||||
double softmax;
|
||||
double hardmax;
|
||||
float value;
|
||||
float hardmin;
|
||||
float softmin;
|
||||
float softmax;
|
||||
float hardmax;
|
||||
} ZoneRangeCondition;
|
||||
|
||||
Zone* zoneCreate();
|
||||
|
@ -24,22 +24,22 @@ void zoneDelete(Zone* zone);
|
|||
void zoneSave(PackStream* stream, Zone* zone);
|
||||
void zoneLoad(PackStream* stream, Zone* zone);
|
||||
void zoneCopy(Zone* source, Zone* destination);
|
||||
void zoneIncludeCircleArea(Zone* zone, double value, double centerx, double centerz, double softradius, double hardradius);
|
||||
void zoneExcludeCircleArea(Zone* zone, double centerx, double centerz, double softradius, double hardradius);
|
||||
void zoneIncludeCircleArea(Zone* zone, float value, float centerx, float centerz, float softradius, float hardradius);
|
||||
void zoneExcludeCircleArea(Zone* zone, float centerx, float centerz, float softradius, float hardradius);
|
||||
|
||||
int zoneAddHeightRange(Zone* zone);
|
||||
int zoneGetHeightRangeCount(Zone* zone);
|
||||
int zoneGetHeightRange(Zone* zone, int position, ZoneRangeCondition* range);
|
||||
int zoneSetHeightRange(Zone* zone, int position, ZoneRangeCondition* range);
|
||||
int zoneAddHeightRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||
int zoneAddHeightRangeQuick(Zone* zone, float value, float hardmin, float softmin, float softmax, float hardmax);
|
||||
|
||||
int zoneAddSlopeRange(Zone* zone);
|
||||
int zoneGetSlopeRangeCount(Zone* zone);
|
||||
int zoneGetSlopeRange(Zone* zone, int position, ZoneRangeCondition* range);
|
||||
int zoneSetSlopeRange(Zone* zone, int position, ZoneRangeCondition* range);
|
||||
int zoneAddSlopeRangeQuick(Zone* zone, double value, double hardmin, double softmin, double softmax, double hardmax);
|
||||
int zoneAddSlopeRangeQuick(Zone* zone, float value, float hardmin, float softmin, float softmax, float hardmax);
|
||||
|
||||
double zoneGetValue(Zone* zone, Vector3 location, Vector3 normal);
|
||||
float zoneGetValue(Zone* zone, Vector3 location, Vector3 normal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue