~rabbits/moogle

83e4ab3beafaee6268a47e0c8b6133b26158cc09 — neauoire 1 year, 5 months ago c31fca5
Added symmetry effect to main
3 files changed, 23 insertions(+), 25 deletions(-)

M build.sh
D lib/effects.c
M src/moogle.c
M build.sh => build.sh +2 -2
@@ 10,10 10,10 @@ rm -f ./bin/moogle
mkdir -p bin

# debug(slow)
cc -std=c89 -DDEBUG -Wall -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/moogle.c -L/usr/local/lib -lSDL2 -lm -o bin/moogle
# cc -std=c89 -DDEBUG -Wall -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/moogle.c -L/usr/local/lib -lSDL2 -lm -o bin/moogle

# build(fast)
# cc src/moogle.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -L/usr/local/lib -lSDL2 -lm -o bin/moogle
cc src/moogle.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -L/usr/local/lib -lSDL2 -lm -o bin/moogle

# Size
echo "Size: $(du -sk ./bin/moogle)"

D lib/effects.c => lib/effects.c +0 -18
@@ 1,18 0,0 @@

Mesh *
symmetry(Mesh *m, double x, double y, double z, int color)
{
	int i, el, vl = m->verticeslen;
	for(i = 0; i < vl; i++)
		addvertex(m,
			m->vertices[i].x * x,
			m->vertices[i].y * y,
			m->vertices[i].z * z);
	el = m->edgeslen;
	for(i = 0; i < el; i++)
		addedge(m,
			el + 1 + m->edges[i].a,
			el + 1 + m->edges[i].b,
			color);
	return m;
}
\ No newline at end of file

M src/moogle.c => src/moogle.c +21 -5
@@ 656,12 656,12 @@ rotate(Mesh *m, double pitch, double yaw, double roll)
}

Mesh *
extrude(Mesh *m, Point3d t, int color)
extrude(Mesh *m, double x, double y, double z, int color)
{
	int i, j, vl = m->verticeslen, el = m->edgeslen;
	for(i = 0; i < vl; i++) {
		Point3d *a = &m->vertices[i];
		addedge(m, &m->vertices[i], addvertex(m, a->x + t.x, a->y + t.y, a->z + t.z), color);
		addedge(m, &m->vertices[i], addvertex(m, a->x + x, a->y + y, a->z + z), color);
	}
	for(i = 0; i < el; i++) {
		Edge *e0 = &m->edges[i];


@@ 676,6 676,24 @@ extrude(Mesh *m, Point3d t, int color)
	return m;
}

Mesh *
symmetry(Mesh *m, double x, double y, double z, int color)
{
	int i, el, vl = m->verticeslen;
	for(i = 0; i < vl; i++)
		addvertex(m,
			m->vertices[i].x * x,
			m->vertices[i].y * y,
			m->vertices[i].z * z);
	el = m->edgeslen;
	for(i = 0; i < el; i++)
		addedge(m,
			el + 1 + m->edges[i].a,
			el + 1 + m->edges[i].b,
			color);
	return m;
}

/* Primitives */

Mesh *


@@ 730,9 748,7 @@ createplane(Scene *s, double width, double height, double xsegs, double ysegs, i
Mesh *
createbox(Scene *s, double width, double height, double depth, int color)
{
	Mesh *m = createplane(s, width, height, 1, 1, color);
	extrude(m, Pt3d(0, 0, depth), color);
	return m;
	return extrude(createplane(s, width, height, 1, 1, color), 0, 0, depth, color);
}

Mesh *