1 /********************************************************************** 2 Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved. 3 4 Permission is hereby granted, free of charge, to any person obtaining a copy 5 of this software and associated documentation files (the "Software"), to deal 6 in the Software without restriction, including without limitation the rights 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 copies of the Software, and to permit persons to whom the Software is 9 furnished to do so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included in 12 all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 THE SOFTWARE. 21 ********************************************************************/ 22 23 module radeonrays.math.int3; 24 25 import radeonrays.math.float3; 26 import radeonrays.math.int2; 27 28 extern(C++,"RadeonRays") 29 { 30 struct int3 31 { 32 public: 33 /*int3(int xx = 0, int yy = 0, int zz = 0) : x(xx), y(yy), z(zz) {} 34 int3(int2 v) : x(v.x), y(v.y), z(0) {} 35 36 int& operator [](int i) { return *(&x + i); } 37 int operator [](int i) const { return *(&x + i); } 38 int3 operator-() const { return int3(-x, -y, -z); } 39 40 int sqnorm() const { return x*x + y*y; } 41 42 operator float3() { return float3((float)x, (float)y, (float)z); } 43 44 int3& operator += (int3 const& o) { x += o.x; y += o.y; z += o.z; return *this; } 45 int3& operator -= (int3 const& o) { x -= o.x; y -= o.y; z -= o.z; return *this; } 46 int3& operator *= (int3 const& o) { x *= o.x; y *= o.y; z *= o.z; return *this; } 47 int3& operator *= (int c) { x *= c; y *= c; z *= c; return *this; }*/ 48 49 int x, y, z; 50 } 51 52 53 /*inline int3 operator+(int3 const& v1, int3 const& v2) 54 { 55 int3 res = v1; 56 return res+=v2; 57 } 58 59 inline int3 operator-(int3 const& v1, int3 const& v2) 60 { 61 int3 res = v1; 62 return res-=v2; 63 } 64 65 inline int3 operator*(int3 const& v1, int3 const& v2) 66 { 67 int3 res = v1; 68 return res*=v2; 69 } 70 71 inline int3 operator*(int3 const& v1, int c) 72 { 73 int3 res = v1; 74 return res*=c; 75 } 76 77 inline int3 operator*(int c, int3 const& v1) 78 { 79 return operator*(v1, c); 80 } 81 82 inline int dot(int3 const& v1, int3 const& v2) 83 { 84 return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; 85 } 86 87 88 inline int3 vmin(int3 const& v1, int3 const& v2) 89 { 90 return int3(std::min(v1.x, v2.x), std::min(v1.y, v2.y), std::min(v1.z, v2.z)); 91 } 92 93 inline int3 vmax(int3 const& v1, int3 const& v2) 94 { 95 return int3(std::max(v1.x, v2.x), std::max(v1.y, v2.y), std::max(v1.z, v2.z)); 96 }*/ 97 }