aboutsummaryrefslogtreecommitdiffstats
path: root/builtins
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2010-06-09 13:17:00 -0700
committerKenneth Graunke <[email protected]>2010-06-09 13:17:00 -0700
commit29b22287fe18afe5b2c55878a59046edad544089 (patch)
tree53603d59c642168219b8bb51df3725719765908a /builtins
parentcdf1726ffdb3fcb8f536f24ee926941cd5043268 (diff)
Implement 'distance' builtin.
Diffstat (limited to 'builtins')
-rw-r--r--builtins/110/distance33
1 files changed, 33 insertions, 0 deletions
diff --git a/builtins/110/distance b/builtins/110/distance
new file mode 100644
index 00000000000..a2309c484f9
--- /dev/null
+++ b/builtins/110/distance
@@ -0,0 +1,33 @@
+((function distance
+ (signature float
+ (parameters
+ (declare (in) float p0)
+ (declare (in) float p1))
+ ((declare () float p)
+ (assign (constant bool (1)) (var_ref p) (expression float - (var_ref p0) (var_ref p1)))
+ (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
+
+ (signature float
+ (parameters
+ (declare (in) vec2 p0)
+ (declare (in) vec2 p1))
+ ((declare () vec2 p)
+ (assign (constant bool (1)) (var_ref p) (expression vec2 - (var_ref p0) (var_ref p1)))
+ (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
+
+ (signature float
+ (parameters
+ (declare (in) vec3 p0)
+ (declare (in) vec3 p1))
+ ((declare () vec3 p)
+ (assign (constant bool (1)) (var_ref p) (expression vec3 - (var_ref p0) (var_ref p1)))
+ (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
+
+ (signature float
+ (parameters
+ (declare (in) vec4 p0)
+ (declare (in) vec4 p1))
+ ((declare () vec4 p)
+ (assign (constant bool (1)) (var_ref p) (expression vec4 - (var_ref p0) (var_ref p1)))
+ (return (expression float sqrt (expression float dot (var_ref p) (var_ref p))))))
+))