mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-16 22:08:28 +01:00
Group gravity files into their own directory
Also replace non-FFT gravity with "no gravity"; fine for render.
This commit is contained in:
parent
159d0eb4b7
commit
b9c8817386
3
.github/build.sh
vendored
3
.github/build.sh
vendored
@ -198,9 +198,6 @@ esac
|
||||
if [[ $PACKAGE_MODE == nohttp ]]; then
|
||||
meson_configure+=$'\t'-Dhttp=false
|
||||
fi
|
||||
if [[ $PACKAGE_MODE == nogravfft ]]; then
|
||||
meson_configure+=$'\t'-Dgravfft=false
|
||||
fi
|
||||
if [[ $PACKAGE_MODE == nolua ]]; then
|
||||
meson_configure+=$'\t'-Dlua=none
|
||||
fi
|
||||
|
1
.github/prepare.py
vendored
1
.github/prepare.py
vendored
@ -83,7 +83,6 @@ for arch, platform, libc, statdyn, bplatform, runson, suff
|
||||
( 'x86_64', 'linux', 'gnu', 'static', 'linux', 'ubuntu-18.04', '', False, True, '.dbg', 'appimage', None, 'release' ),
|
||||
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-18.04', '', False, False, None, None, None, 'debug' ),
|
||||
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-18.04', '', False, False, None, 'nohttp', None, 'debug' ),
|
||||
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-18.04', '', False, False, None,'nogravfft', None, 'debug' ),
|
||||
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-18.04', '', False, False, None, 'nolua', None, 'debug' ),
|
||||
( 'x86_64', 'linux', 'gnu', 'dynamic', 'linux', 'ubuntu-18.04', '', False, False, None, None, None, 'release' ),
|
||||
# ( 'x86_64', 'windows', 'mingw', 'static', 'linux', 'ubuntu-20.04', '', False, False, None, None, None, 'debug' ), # ubuntu-20.04 doesn't have windows TLS headers somehow and I haven't yet figured out how to get them
|
||||
|
@ -179,9 +179,7 @@ if host_platform == 'android'
|
||||
endif
|
||||
curl_dep = enable_http ? dependency('libcurl', static: is_static) : []
|
||||
|
||||
enable_gravfft = get_option('gravfft')
|
||||
fftw_dep = enable_gravfft ? dependency('fftw3f', static: is_static) : []
|
||||
|
||||
fftw_dep = dependency('fftw3f', static: is_static)
|
||||
threads_dep = dependency('threads')
|
||||
zlib_dep = dependency('zlib', static: is_static)
|
||||
png_dep = dependency('libpng16', static: is_static)
|
||||
|
@ -30,12 +30,6 @@ option(
|
||||
value: true,
|
||||
description: 'Enable HTTP via libcurl'
|
||||
)
|
||||
option(
|
||||
'gravfft',
|
||||
type: 'boolean',
|
||||
value: true,
|
||||
description: 'Enable FFT gravity via libfftw3'
|
||||
)
|
||||
option(
|
||||
'snapshot',
|
||||
type: 'boolean',
|
||||
|
@ -6,7 +6,6 @@ constexpr bool X86 = @X86@;
|
||||
constexpr bool BETA = @BETA@;
|
||||
constexpr bool SNAPSHOT = @SNAPSHOT@;
|
||||
constexpr bool MOD = @MOD@;
|
||||
constexpr bool GRAVFFT = @GRAVFFT@;
|
||||
constexpr bool NOHTTP = @NOHTTP@;
|
||||
constexpr bool LUACONSOLE = @LUACONSOLE@;
|
||||
constexpr bool ALLOW_FAKE_NEWER_VERSION = @ALLOW_FAKE_NEWER_VERSION@;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "simulation/ElementGraphics.h"
|
||||
#include "simulation/ElementClasses.h"
|
||||
#include "simulation/Air.h"
|
||||
#include "simulation/Gravity.h"
|
||||
#include "simulation/gravity/Gravity.h"
|
||||
#include <cmath>
|
||||
|
||||
constexpr auto VIDXRES = WINDOWW;
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "graphics/Renderer.h"
|
||||
#include "simulation/Air.h"
|
||||
#include "simulation/GOLString.h"
|
||||
#include "simulation/Gravity.h"
|
||||
#include "simulation/gravity/Gravity.h"
|
||||
#include "simulation/Simulation.h"
|
||||
#include "simulation/Snapshot.h"
|
||||
#include "simulation/SnapshotDelta.h"
|
||||
|
@ -51,10 +51,6 @@ inline ByteString IntroText()
|
||||
{
|
||||
sb << " LUACONSOLE";
|
||||
}
|
||||
if constexpr (GRAVFFT)
|
||||
{
|
||||
sb << " GRAVFFT";
|
||||
}
|
||||
#ifdef REALISTIC
|
||||
sb << " REALISTIC";
|
||||
#endif
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "simulation/Simulation.h"
|
||||
#include "simulation/Air.h"
|
||||
#include "simulation/Gravity.h"
|
||||
#include "simulation/gravity/Gravity.h"
|
||||
|
||||
#include "prefs/GlobalPrefs.h"
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "graphics/Graphics.h"
|
||||
#include "graphics/Renderer.h"
|
||||
#include "simulation/ElementCommon.h"
|
||||
#include "simulation/Gravity.h"
|
||||
#include "simulation/gravity/Gravity.h"
|
||||
#include "simulation/Simulation.h"
|
||||
#include "simulation/SimulationData.h"
|
||||
#include "gui/dialogues/ConfirmPrompt.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "SimTool.h"
|
||||
#include "Snapshot.h"
|
||||
#include "Air.h"
|
||||
#include "Gravity.h"
|
||||
#include "gravity/Gravity.h"
|
||||
#include "common/tpt-rand.h"
|
||||
#include "common/tpt-compat.h"
|
||||
#include "client/GameSave.h"
|
||||
|
@ -1,53 +0,0 @@
|
||||
#include "Gravity.h"
|
||||
#include "Misc.h"
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
// gravity without fast Fourier transforms
|
||||
|
||||
void Gravity::get_result()
|
||||
{
|
||||
memcpy(gravy, th_gravy, NCELL*sizeof(float));
|
||||
memcpy(gravx, th_gravx, NCELL*sizeof(float));
|
||||
memcpy(gravp, th_gravp, NCELL*sizeof(float));
|
||||
}
|
||||
|
||||
void Gravity::update_grav(void)
|
||||
{
|
||||
th_gravchanged = 1;
|
||||
membwand(th_gravmap, gravmask, NCELL*sizeof(float), NCELL*sizeof(unsigned));
|
||||
for (int i = 0; i < YCELLS; i++)
|
||||
{
|
||||
for (int j = 0; j < XCELLS; j++)
|
||||
{
|
||||
if (th_ogravmap[i*XCELLS+j] != th_gravmap[i*XCELLS+j])
|
||||
{
|
||||
for (int y = 0; y < YCELLS; y++)
|
||||
{
|
||||
for (int x = 0; x < XCELLS; x++)
|
||||
{
|
||||
if (x == j && y == i)//Ensure it doesn't calculate with itself
|
||||
continue;
|
||||
auto distance = hypotf(j - x, i - y);
|
||||
float val;
|
||||
val = th_gravmap[i*XCELLS+j] - th_ogravmap[i*XCELLS+j];
|
||||
th_gravx[y*XCELLS+x] += M_GRAV * val * (j - x) / powf(distance, 3.0f);
|
||||
th_gravy[y*XCELLS+x] += M_GRAV * val * (i - y) / powf(distance, 3.0f);
|
||||
th_gravp[y*XCELLS+x] += M_GRAV * val / powf(distance, 2.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
memcpy(th_ogravmap, th_gravmap, NCELL*sizeof(float));
|
||||
}
|
||||
|
||||
GravityPtr Gravity::Create()
|
||||
{
|
||||
return GravityPtr(new Gravity(CtorTag{}));
|
||||
}
|
||||
|
||||
void GravityDeleter::operator ()(Gravity *ptr) const
|
||||
{
|
||||
delete ptr;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#include "common/tpt-rand.h"
|
||||
#include "graphics/Renderer.h"
|
||||
#include "simulation/ElementGraphics.h"
|
||||
#include "simulation/Gravity.h"
|
||||
#include "simulation/gravity/Gravity.h"
|
||||
#include "simulation/Simulation.h"
|
||||
#include "Misc.h"
|
||||
#include "ToolClasses.h"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "Simulation.h"
|
||||
#include "Air.h"
|
||||
#include "ElementClasses.h"
|
||||
#include "Gravity.h"
|
||||
#include "gravity/Gravity.h"
|
||||
#include "ToolClasses.h"
|
||||
#include "SimulationData.h"
|
||||
#include "GOLString.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "BuiltinGOL.h"
|
||||
#include "MenuSection.h"
|
||||
#include "CoordStack.h"
|
||||
#include "GravityPtr.h"
|
||||
#include "gravity/GravityPtr.h"
|
||||
#include "Element.h"
|
||||
#include "SimulationConfig.h"
|
||||
#include <cstring>
|
||||
|
@ -1,14 +1,12 @@
|
||||
#include "Gravity.h"
|
||||
|
||||
#include "simulation/CoordStack.h"
|
||||
#include "simulation/Simulation.h"
|
||||
#include "simulation/SimulationData.h"
|
||||
#include "Misc.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "CoordStack.h"
|
||||
#include "Misc.h"
|
||||
#include "Simulation.h"
|
||||
#include "SimulationData.h"
|
||||
|
||||
Gravity::Gravity(CtorTag)
|
||||
{
|
||||
// Allocate full size Gravmaps
|
@ -4,7 +4,7 @@
|
||||
#include <cmath>
|
||||
#include <fftw3.h>
|
||||
|
||||
struct FftGravity : public Gravity
|
||||
struct GravityImpl : public Gravity
|
||||
{
|
||||
bool grav_fft_status = false;
|
||||
float *th_ptgravx = nullptr;
|
||||
@ -19,20 +19,20 @@ struct FftGravity : public Gravity
|
||||
void grav_fft_init();
|
||||
void grav_fft_cleanup();
|
||||
|
||||
FftGravity() : Gravity(CtorTag{})
|
||||
GravityImpl() : Gravity(CtorTag{})
|
||||
{
|
||||
}
|
||||
|
||||
~FftGravity();
|
||||
~GravityImpl();
|
||||
};
|
||||
|
||||
FftGravity::~FftGravity()
|
||||
GravityImpl::~GravityImpl()
|
||||
{
|
||||
stop_grav_async();
|
||||
grav_fft_cleanup();
|
||||
}
|
||||
|
||||
void FftGravity::grav_fft_init()
|
||||
void GravityImpl::grav_fft_init()
|
||||
{
|
||||
int xblock2 = XCELLS*2;
|
||||
int yblock2 = YCELLS*2;
|
||||
@ -91,7 +91,7 @@ void FftGravity::grav_fft_init()
|
||||
grav_fft_status = true;
|
||||
}
|
||||
|
||||
void FftGravity::grav_fft_cleanup()
|
||||
void GravityImpl::grav_fft_cleanup()
|
||||
{
|
||||
if (!grav_fft_status) return;
|
||||
fftwf_free(th_ptgravxt);
|
||||
@ -117,7 +117,7 @@ void Gravity::get_result()
|
||||
|
||||
void Gravity::update_grav()
|
||||
{
|
||||
auto *fftGravity = static_cast<FftGravity *>(this);
|
||||
auto *fftGravity = static_cast<GravityImpl *>(this);
|
||||
if (!fftGravity->grav_fft_status)
|
||||
fftGravity->grav_fft_init();
|
||||
|
||||
@ -193,10 +193,10 @@ void Gravity::update_grav()
|
||||
|
||||
GravityPtr Gravity::Create()
|
||||
{
|
||||
return GravityPtr(new FftGravity());
|
||||
return GravityPtr(new GravityImpl());
|
||||
}
|
||||
|
||||
void GravityDeleter::operator ()(Gravity *ptr) const
|
||||
{
|
||||
delete static_cast<FftGravity *>(ptr);
|
||||
delete static_cast<GravityImpl *>(ptr);
|
||||
}
|
26
src/simulation/gravity/Null.cpp
Normal file
26
src/simulation/gravity/Null.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "Gravity.h"
|
||||
#include "Misc.h"
|
||||
#include <cstring>
|
||||
|
||||
// gravity without fast Fourier transforms
|
||||
|
||||
void Gravity::get_result()
|
||||
{
|
||||
memcpy(gravy, th_gravy, NCELL*sizeof(float));
|
||||
memcpy(gravx, th_gravx, NCELL*sizeof(float));
|
||||
memcpy(gravp, th_gravp, NCELL*sizeof(float));
|
||||
}
|
||||
|
||||
void Gravity::update_grav(void)
|
||||
{
|
||||
}
|
||||
|
||||
GravityPtr Gravity::Create()
|
||||
{
|
||||
return GravityPtr(new Gravity(CtorTag{}));
|
||||
}
|
||||
|
||||
void GravityDeleter::operator ()(Gravity *ptr) const
|
||||
{
|
||||
delete ptr;
|
||||
}
|
6
src/simulation/gravity/meson.build
Normal file
6
src/simulation/gravity/meson.build
Normal file
@ -0,0 +1,6 @@
|
||||
simulation_files += files(
|
||||
'Common.cpp',
|
||||
)
|
||||
|
||||
powder_files += files('Fft.cpp')
|
||||
render_files += files('Null.cpp')
|
@ -3,7 +3,6 @@ simulation_files = files(
|
||||
'Element.cpp',
|
||||
'ElementClasses.cpp',
|
||||
'GOLString.cpp',
|
||||
'Gravity.cpp',
|
||||
'Particle.cpp',
|
||||
'SaveRenderer.cpp',
|
||||
'Sign.cpp',
|
||||
@ -13,6 +12,7 @@ simulation_files = files(
|
||||
|
||||
subdir('elements')
|
||||
subdir('simtools')
|
||||
subdir('gravity')
|
||||
|
||||
powder_files += simulation_files
|
||||
render_files += simulation_files
|
||||
@ -26,10 +26,3 @@ powder_files += files(
|
||||
render_files += files(
|
||||
'NoToolClasses.cpp',
|
||||
)
|
||||
if enable_gravfft
|
||||
powder_files += files('FftGravity.cpp')
|
||||
else
|
||||
powder_files += files('PlainGravity.cpp')
|
||||
endif
|
||||
conf_data.set('GRAVFFT', enable_gravfft ? 'true' : 'false')
|
||||
render_files += files('PlainGravity.cpp')
|
||||
|
Loading…
x
Reference in New Issue
Block a user