mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-23 16:08:51 -05:00
made it to work with my windows compiler
This commit is contained in:
parent
dd9e82f5bc
commit
15f27a1937
@ -364,6 +364,7 @@ Doing now (most important at the top):
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "guiMainMenu.h"
|
#include "guiMainMenu.h"
|
||||||
#include "mineral.h"
|
#include "mineral.h"
|
||||||
|
#include "noise.h"
|
||||||
|
|
||||||
IrrlichtWrapper *g_irrlicht;
|
IrrlichtWrapper *g_irrlicht;
|
||||||
|
|
||||||
@ -1545,12 +1546,20 @@ int main(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
Run unit tests
|
Run unit tests
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if((ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false)
|
if((ENABLE_TESTS && cmd_args.getFlag("disable-unittests") == false)
|
||||||
|| cmd_args.getFlag("enable-unittests") == true)
|
|| cmd_args.getFlag("enable-unittests") == true)
|
||||||
{
|
{
|
||||||
run_tests();
|
run_tests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*for(s16 y=-100; y<100; y++)
|
||||||
|
for(s16 x=-100; x<100; x++)
|
||||||
|
{
|
||||||
|
std::cout<<noise2d_gradient((double)x/10,(double)y/10, 32415)<<std::endl;
|
||||||
|
}
|
||||||
|
return 0;*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Some parameters
|
Some parameters
|
||||||
*/
|
*/
|
||||||
|
@ -2009,9 +2009,10 @@ double tree_amount_2d(u64 seed, v2s16 p)
|
|||||||
double base_rock_level_2d(u64 seed, v2s16 p)
|
double base_rock_level_2d(u64 seed, v2s16 p)
|
||||||
{
|
{
|
||||||
// The base ground level
|
// The base ground level
|
||||||
double base = WATER_LEVEL - 4.0 + 25. * noise2d_perlin(
|
double base = (double)WATER_LEVEL - 4.0 + 25. * noise2d_perlin(
|
||||||
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
|
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
|
||||||
(seed>>32)+654879876, 6, 0.6);
|
(seed>>32)+654879876, 6, 0.6);
|
||||||
|
|
||||||
/*// A bit hillier one
|
/*// A bit hillier one
|
||||||
double base2 = WATER_LEVEL - 4.0 + 40. * noise2d_perlin(
|
double base2 = WATER_LEVEL - 4.0 + 40. * noise2d_perlin(
|
||||||
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
|
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
|
||||||
@ -2020,7 +2021,7 @@ double base_rock_level_2d(u64 seed, v2s16 p)
|
|||||||
base = base2;*/
|
base = base2;*/
|
||||||
#if 1
|
#if 1
|
||||||
// Higher ground level
|
// Higher ground level
|
||||||
double higher = WATER_LEVEL + 13. + 50. * noise2d_perlin(
|
double higher = (double)WATER_LEVEL + 13. + 50. * noise2d_perlin(
|
||||||
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
|
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
|
||||||
seed+85039, 6, 0.69);
|
seed+85039, 6, 0.69);
|
||||||
//higher = 30; // For debugging
|
//higher = 30; // For debugging
|
||||||
@ -2046,7 +2047,7 @@ double base_rock_level_2d(u64 seed, v2s16 p)
|
|||||||
/*double a = 0.5 + b * (a_off + noise2d_perlin(
|
/*double a = 0.5 + b * (a_off + noise2d_perlin(
|
||||||
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
|
0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
|
||||||
seed-359, 6, 0.7));*/
|
seed-359, 6, 0.7));*/
|
||||||
double a = 0.5 + b * (a_off + noise2d_perlin(
|
double a = (double)0.5 + b * (a_off + noise2d_perlin(
|
||||||
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
|
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
|
||||||
seed-359, 5, 0.60));
|
seed-359, 5, 0.60));
|
||||||
// Limit
|
// Limit
|
||||||
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#define NOISE_MAGIC_X 1619
|
#define NOISE_MAGIC_X 1619
|
||||||
#define NOISE_MAGIC_Y 31337
|
#define NOISE_MAGIC_Y 31337
|
||||||
@ -62,16 +63,23 @@ double noise2d_gradient(double x, double y, int seed)
|
|||||||
{
|
{
|
||||||
int x0 = (x > 0.0 ? (int)x : (int)x - 1);
|
int x0 = (x > 0.0 ? (int)x : (int)x - 1);
|
||||||
int y0 = (y > 0.0 ? (int)y : (int)y - 1);
|
int y0 = (y > 0.0 ? (int)y : (int)y - 1);
|
||||||
double xl = x-x0;
|
double xl = x - (double)x0;
|
||||||
double yl = y-y0;
|
double yl = y - (double)y0;
|
||||||
int n00 = (int)((noise2d(x0, y0, seed)+1)*8);
|
int n00 = (int)((noise2d(x0, y0, seed)+1)*8);
|
||||||
int n10 = (int)((noise2d(x0+1, y0, seed)+1)*8);
|
int n10 = (int)((noise2d(x0+1, y0, seed)+1)*8);
|
||||||
int n01 = (int)((noise2d(x0, y0+1, seed)+1)*8);
|
int n01 = (int)((noise2d(x0, y0+1, seed)+1)*8);
|
||||||
int n11 = (int)((noise2d(x0+1, y0+1, seed)+1)*8);
|
int n11 = (int)((noise2d(x0+1, y0+1, seed)+1)*8);
|
||||||
|
/* In this format, these fail to work on MSVC8 if n00 < 4
|
||||||
double s = dotProduct(cos_lookup[n00], cos_lookup[(n00-4)%16], xl, yl);
|
double s = dotProduct(cos_lookup[n00], cos_lookup[(n00-4)%16], xl, yl);
|
||||||
double u = dotProduct(-cos_lookup[n10], cos_lookup[(n10-4)%16], 1.-xl, yl);
|
double u = dotProduct(-cos_lookup[n10], cos_lookup[(n10-4)%16], 1.-xl, yl);
|
||||||
double v = dotProduct(cos_lookup[n01], -cos_lookup[(n01-4)%16], xl, 1.-yl);
|
double v = dotProduct(cos_lookup[n01], -cos_lookup[(n01-4)%16], xl, 1.-yl);
|
||||||
double w = dotProduct(-cos_lookup[n11], -cos_lookup[(n11-4)%16], 1.-xl, 1.-yl);
|
double w = dotProduct(-cos_lookup[n11], -cos_lookup[(n11-4)%16], 1.-xl, 1.-yl);*/
|
||||||
|
double s = dotProduct(cos_lookup[n00], cos_lookup[(n00+12)%16], xl, yl);
|
||||||
|
double u = dotProduct(-cos_lookup[n10], cos_lookup[(n10+12)%16], 1.-xl, yl);
|
||||||
|
double v = dotProduct(cos_lookup[n01], -cos_lookup[(n01+12)%16], xl, 1.-yl);
|
||||||
|
double w = dotProduct(-cos_lookup[n11], -cos_lookup[(n11+12)%16], 1.-xl, 1.-yl);
|
||||||
|
/*std::cout<<"x="<<x<<" y="<<y<<" x0="<<x0<<" y0="<<y0<<" xl="<<xl<<" yl="<<yl<<" n00="<<n00<<" n10="<<n01<<" s="<<s<<std::endl;
|
||||||
|
std::cout<<"cos_lookup[n00]="<<(cos_lookup[n00])<<" cos_lookup[(n00-4)%16]="<<(cos_lookup[(n00-4)%16])<<std::endl;*/
|
||||||
return biLinearInterpolation(s,u,v,w,xl,yl);
|
return biLinearInterpolation(s,u,v,w,xl,yl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user