Commits

Cliff Biffle  committed 425b76a

Moved computePerspective out of types.h into a new header, utility.h, and stuffed the vector math routines in there too.

  • Participants
  • Parent commits b682cc1

Comments (0)

Files changed (3)

File KVDepthView.m

 
 #import "KVDepthView.h"
 #import "trackball.h"
+#import "utility.h"
 
 @interface KVDepthView (Private)
 + (NSOpenGLPixelFormat *) makePixelFormat;
   }
 }
 
-static inline void vector_subtract(const vec3f_t *a, const vec3f_t *b, vec3f_t *out) {
-	*out = (vec3f_t) {
-		a->x - b->x,
-		a->y - b->y,
-		a->z - b->z
-	};
-}
-
-static inline void cross_product(const vec3f_t *a, const vec3f_t *b, vec3f_t *out) {
-	*out = (vec3f_t) {
-		a->y * b->z - a->z * b->y,
-		a->z * b->x - a->x * b->z,
-		a->x * b->y - a->y * b->x
-	};		
-}
-
-static inline void compute_normal(const vec3f_t *p1, const vec3f_t *p2, const vec3f_t *p3, vec3f_t *out) {
-	vec3f_t a, b;
-	vector_subtract(p3, p2, &a);
-	vector_subtract(p1, p2, &b);
-	
-	cross_product(&a, &b, out);
-}
-
 #define FALLOFF (9.F)
 
 - (void) drawDepthFieldAsTris: (NSData *)field 
   uint16_t samples[480][640];
 } depth_t;
 
-static inline vec3f_t correctPerspective(int x, int y, float z) {
-  float dr = 1.F + z;
-  return (vec3f_t) {
-    .x = (x - 320) * dr,
-    .y = (y - 240) * dr,
-    .z = z
-  };
-}
-
-#endif __types_h__
+#endif __types_h__
+/*
+ * Copyright 2010 Cliff L. Biffle.  All Rights Reserved.
+ * Use of this source code is governed by the Apache License 2.0,
+ * which can be found in the LICENSE file.
+ */
+
+#ifndef __utility_h__
+#define __utility_h__
+
+#include "types.h"
+
+static inline vec3f_t correctPerspective(int x, int y, float z) {
+  float dr = 1.F + z;
+  return (vec3f_t) {
+    .x = (x - 320) * dr,
+    .y = (y - 240) * dr,
+    .z = z
+  };
+}
+
+static inline void vector_subtract(const vec3f_t *a, const vec3f_t *b, vec3f_t *out) {
+	*out = (vec3f_t) {
+		a->x - b->x,
+		a->y - b->y,
+		a->z - b->z
+	};
+}
+
+static inline void cross_product(const vec3f_t *a, const vec3f_t *b, vec3f_t *out) {
+	*out = (vec3f_t) {
+		a->y * b->z - a->z * b->y,
+		a->z * b->x - a->x * b->z,
+		a->x * b->y - a->y * b->x
+	};		
+}
+
+static inline void compute_normal(const vec3f_t *p1, const vec3f_t *p2, const vec3f_t *p3, vec3f_t *out) {
+	vec3f_t a, b;
+	vector_subtract(p3, p2, &a);
+	vector_subtract(p1, p2, &b);
+	
+	cross_product(&a, &b, out);
+}
+
+#endif __utility_h__