summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2017-02-02 02:43:48 -0600
committerepoch <epoch@hacking.allowed.org>2017-02-02 02:43:48 -0600
commit9e231504bdc32c814abbe914133587913040ccbe (patch)
tree57933f15e9de0dcbf7fdf5151a72c6a737d19c50 /src
parentd5cd6145b1c1e99ccbd2b48ccb1f02f4a9a635f6 (diff)
downloadhackvr-9e231504bdc32c814abbe914133587913040ccbe.tar.gz
hackvr-9e231504bdc32c814abbe914133587913040ccbe.zip
moved polygon array copy and selected object stuff to outside of loop.
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 0852ec4..17abb21 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -371,6 +371,12 @@ void draw_screen() {
clear_backbuffer();
real oldx=camera.p.x;
real oldz=camera.p.z;
+
+ for(i=0;global.shape[i];i++) zs[i].s=global.shape[i];
+ for(i=0;global.shape[i];i++) zs[i].d=shitdist(zs[i].s,camera.p);
+ qsort(&zs,i,sizeof(zs[0]),(__compar_fn_t)compar);//sort these zs structs based on d.
+ if(i > 0 && zs[i-1].s) strcpy(global.selected_object,zs[i-1].s->id);
+
if(gra_global.split_screen > 1) {
camera.p.z-=(gra_global.split_flip)*((gra_global.split/gra_global.split_screen)*cosl(d2r(camera.yr.d+180)));
camera.p.x-=(gra_global.split_flip)*((gra_global.split/gra_global.split_screen)*sinl(d2r(camera.yr.d+180)));
@@ -425,24 +431,10 @@ void draw_screen() {
// draw_c2_line((c2_t){10,10},(c2_t){-10,10});
// }
- //apply rotation?
- // load up the triangles to render... after applying rotation?
for(i=0;global.shape[i];i++) {
- zs[i].s=global.shape[i];
- //rotate_shape(zs[i].s);
- }
- //
- if(1) {//global.zsort) {
- for(i=0;global.shape[i];i++) {
- zs[i].d=shitdist(zs[i].s,camera.p);
- }
- qsort(&zs,i,sizeof(zs[0]),(__compar_fn_t)compar);//sort these zs structs based on d.
- }
- if(i > 0) {
- if(zs[i-1].s) {
- strcpy(global.selected_object,zs[i-1].s->id);
- }
+ zs[i].d=shitdist(zs[i].s,camera.p);
}
+ qsort(&zs,i,sizeof(zs[0]),(__compar_fn_t)compar);//sort these zs structs based on d.
//draw all triangles
if(global.debug) {
snprintf(tmp,sizeof(tmp)-1,"selected object: %s",global.selected_object);