Détection automatique des dépendances dans le Makefile.
This commit is contained in:
parent
dcf00b464d
commit
753c61072d
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,4 +2,6 @@ simple-terrain
|
|||
display
|
||||
roam
|
||||
roads
|
||||
rules
|
||||
*.o
|
||||
.*.d
|
||||
|
|
25
Makefile
25
Makefile
|
@ -4,26 +4,37 @@ CCWARN=-Wall -Wextra -Werror
|
|||
CFLAGS=-O3 $(CCWARN) -g3
|
||||
|
||||
.PHONY: all
|
||||
all: display roads
|
||||
all: display roads rules
|
||||
|
||||
.PHONY: test
|
||||
test: all
|
||||
# ./simple-terrain | display
|
||||
test: display
|
||||
./display
|
||||
|
||||
.PHONY: test
|
||||
test-simple-terrain: simple-terrain
|
||||
./simple-terrain | display
|
||||
|
||||
.PHONY: testroads
|
||||
testroads: all
|
||||
testroads: roads
|
||||
./roads | display
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm simple-terrain display roads rules *.o
|
||||
|
||||
simple-terrain: simple-terrain.c
|
||||
$(CC) $< -o $@
|
||||
|
||||
display: display.o roam.o square.o
|
||||
display: display.o roam.o square.o hash.o
|
||||
$(CC) -lGLEW -lSDL -lGLU $^ -o $@
|
||||
|
||||
roads: roads.o
|
||||
$(CC) -lm $^ -o $@
|
||||
|
||||
# Create objects from C source code
|
||||
rules: rules.o hash.o
|
||||
$(CC) -lm $^ -o $@
|
||||
|
||||
-include .*.d
|
||||
|
||||
%.o: %.c Makefile
|
||||
$(CC) -c $< $(CFLAGS) -o $@
|
||||
$(CC) -MMD -MF .$(@:.o=.d) -c $< $(CFLAGS) -o $@
|
||||
|
|
18
hash.c
Normal file
18
hash.c
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Ce hash donne des bons résultats sur tous les bits de l'entier
|
||||
// généré (pas d'artefacts, répartition homogène des 0 et des 1).
|
||||
unsigned int hash2(unsigned int a, unsigned int b) {
|
||||
unsigned int h = 1;
|
||||
int i;
|
||||
for (i = 0; i < 32; i+=8) {
|
||||
a = a*h + 1;
|
||||
b = b*h + 1;
|
||||
// marche aussi avec 65521.
|
||||
h = (h << 6) + (h << 16) - h + ((a >> i) & 0xff); // h * 65599 + ieme octet de a
|
||||
h = (h << 6) + (h << 16) - h + ((b >> i) & 0xff); // h * 65599 + ieme octet de b
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned int hash3(unsigned int seed, int x, int y) {
|
||||
return hash2(seed,hash2(x, y));
|
||||
}
|
2
hash.h
Normal file
2
hash.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
unsigned int hash2(unsigned int a, unsigned int b);
|
||||
unsigned int hash3(unsigned int seed, int x, int y);
|
20
roam.c
20
roam.c
|
@ -1,4 +1,5 @@
|
|||
#include "roam.h"
|
||||
#include "hash.h"
|
||||
|
||||
/* Implémentation de ROAM
|
||||
* http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.22.1811&rep=rep1&type=pdf
|
||||
|
@ -41,25 +42,6 @@ int getFirstTriangleSize(Triangle* t) {
|
|||
return sqrt(((t->vRight->x - t->vLeft->x)^2) + ((t->vRight->y - t->vLeft->y)^2));
|
||||
}
|
||||
|
||||
// Ce hash donne des bons résultats sur tous les bits de l'entier
|
||||
// généré (pas d'artefacts, répartition homogène des 0 et des 1).
|
||||
unsigned int hash2(unsigned int a, unsigned int b) {
|
||||
unsigned int h = 1;
|
||||
int i;
|
||||
for (i = 0; i < 32; i+=8) {
|
||||
a = a*h + 1;
|
||||
b = b*h + 1;
|
||||
// marche aussi avec 65521.
|
||||
h = (h << 6) + (h << 16) - h + ((a >> i) & 0xff); // h * 65599 + ieme octet de a
|
||||
h = (h << 6) + (h << 16) - h + ((b >> i) & 0xff); // h * 65599 + ieme octet de b
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned int hash3(unsigned int seed, int x, int y) {
|
||||
return hash2(seed,hash2(x, y));
|
||||
}
|
||||
|
||||
/* Interpolation linéaire entre deux points.
|
||||
* (x,y) est le point dont on veut connaître la valeur
|
||||
* (x1,y1)--(x2,y2) est le carré dont on connaît les valeurs
|
||||
|
|
|
@ -38,3 +38,12 @@ Erosion
|
|||
-------
|
||||
|
||||
Modélisation correcte : trop lent. À la place, outil "courbes" de gimp.
|
||||
|
||||
Rivières
|
||||
========
|
||||
|
||||
[Pathfinding pour créer des rivières](http://www.umbrarumregnum.net/articles/creating-rivers).
|
||||
Si on utilise une méthode de coût qui favorise de passer par un petit
|
||||
bout de bruit plutôt que de le contourner, mais favorise le
|
||||
contournement pour une grosse accumulation de bruit, on pourra même
|
||||
simuler l'érosion qui efface les méandres trop petits.
|
||||
|
|
Loading…
Reference in New Issue
Block a user