medfall

A super great game engine
Log | Files | Refs

commit fab996d3bcc3b85ab437a2008d40bd6b486b8d31
parent cd2ba73fb94b59ec2caedec6358a6b594a663d1e
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun Apr 30 02:32:26 +0300

Smooth normals in immediate_sphere

Diffstat:
immediate.cc | 35+++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/immediate.cc b/immediate.cc @@ -61,32 +61,15 @@ void immediate_sphere( float cp1 = dcp; for( u32 p = 0; p < subdivisions; p++ ) { - v3 top_left = centre + v3( - radius * ca0 * sp0, - radius * sa0 * sp0, - radius * cp0 - ); - - v3 top_right = centre + v3( - radius * ca1 * sp0, - radius * sa1 * sp0, - radius * cp0 - ); - - v3 bottom_left = centre + v3( - radius * ca0 * sp1, - radius * sa0 * sp1, - radius * cp1 - ); - - v3 bottom_right = centre + v3( - radius * ca1 * sp1, - radius * sa1 * sp1, - radius * cp1 - ); - - immediate_triangle( ctx, top_left, top_right, bottom_left, colour ); - immediate_triangle( ctx, bottom_left, top_right, bottom_right, colour ); +#define VERT( n ) { centre + radius * n, n, colour, v2( 0, 0 ) } + ImmediateVertex top_left = VERT( v3( ca0 * sp0, sa0 * sp0, cp0 ) ); + ImmediateVertex top_right = VERT( v3( ca1 * sp0, sa1 * sp0, cp0 ) ); + ImmediateVertex bottom_left = VERT( v3( ca0 * sp1, sa0 * sp1, cp1 ) ); + ImmediateVertex bottom_right = VERT( v3( ca1 * sp1, sa1 * sp1, cp1 ) ); +#undef VERT + + immediate_triangle( ctx, top_left, top_right, bottom_left ); + immediate_triangle( ctx, bottom_left, top_right, bottom_right ); sp0 = sp1; cp0 = cp1;