OSDN Git Service

Merge branch 'feature/#36529_SlimDXからSharpDXへの移行' into develop
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / math / BoundingBox.cpp
diff --git a/SlimDXc_Jun2010(VC++2008)/source/math/BoundingBox.cpp b/SlimDXc_Jun2010(VC++2008)/source/math/BoundingBox.cpp
deleted file mode 100644 (file)
index 0d7239c..0000000
+++ /dev/null
@@ -1,236 +0,0 @@
-#include "stdafx.h"\r
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-\r
-#include <d3dx9.h>\r
-\r
-#include "../SlimDXException.h"\r
-#include "../DataStream.h"\r
-\r
-#include "BoundingBox.h"\r
-#include "BoundingSphere.h"\r
-#include "Ray.h"\r
-#include "Plane.h"\r
-\r
-using namespace System;\r
-using namespace System::Globalization;\r
-\r
-namespace SlimDX\r
-{\r
-       BoundingBox::BoundingBox( Vector3 minimum, Vector3 maximum )\r
-       {\r
-               Minimum = minimum;\r
-               Maximum = maximum;\r
-       }\r
-\r
-       array<Vector3>^ BoundingBox::GetCorners()\r
-       {\r
-               array<Vector3>^ results = gcnew array<Vector3>( 8 );\r
-               results[0] = Vector3(Minimum.X, Maximum.Y, Maximum.Z);\r
-               results[1] = Vector3(Maximum.X, Maximum.Y, Maximum.Z);\r
-               results[2] = Vector3(Maximum.X, Minimum.Y, Maximum.Z);\r
-               results[3] = Vector3(Minimum.X, Minimum.Y, Maximum.Z);\r
-               results[4] = Vector3(Minimum.X, Maximum.Y, Minimum.Z);\r
-               results[5] = Vector3(Maximum.X, Maximum.Y, Minimum.Z);\r
-               results[6] = Vector3(Maximum.X, Minimum.Y, Minimum.Z);\r
-               results[7] = Vector3(Minimum.X, Minimum.Y, Minimum.Z);\r
-               return results;\r
-       }\r
-\r
-       ContainmentType BoundingBox::Contains( BoundingBox box1, BoundingBox box2 )\r
-       {\r
-               if( box1.Maximum.X < box2.Minimum.X || box1.Minimum.X > box2.Maximum.X )\r
-                       return ContainmentType::Disjoint;\r
-\r
-               if( box1.Maximum.Y < box2.Minimum.Y || box1.Minimum.Y > box2.Maximum.Y )\r
-                       return ContainmentType::Disjoint;\r
-\r
-               if( box1.Maximum.Z < box2.Minimum.Z || box1.Minimum.Z > box2.Maximum.Z )\r
-                       return ContainmentType::Disjoint;\r
-\r
-               if( box1.Minimum.X <= box2.Minimum.X && box2.Maximum.X <= box1.Maximum.X && box1.Minimum.Y <= box2.Minimum.Y && \r
-                       box2.Maximum.Y <= box1.Maximum.Y && box1.Minimum.Z <= box2.Minimum.Z && box2.Maximum.Z <= box1.Maximum.Z )\r
-                       return ContainmentType::Contains;\r
-\r
-               return ContainmentType::Intersects;\r
-       }\r
-\r
-       ContainmentType BoundingBox::Contains( BoundingBox box, BoundingSphere sphere )\r
-       {\r
-               float dist;\r
-               Vector3 clamped;\r
-\r
-               Vector3::Clamp( sphere.Center, box.Minimum, box.Maximum, clamped );\r
-\r
-               float x = sphere.Center.X - clamped.X;\r
-               float y = sphere.Center.Y - clamped.Y;\r
-               float z = sphere.Center.Z - clamped.Z;\r
-\r
-               dist = (x * x) + (y * y) + (z * z);\r
-               float radius = sphere.Radius;\r
-\r
-               if( dist > (radius * radius) )\r
-                       return ContainmentType::Disjoint;\r
-\r
-               if( box.Minimum.X + radius <= sphere.Center.X && sphere.Center.X <= box.Maximum.X - radius && \r
-                       box.Maximum.X - box.Minimum.X > radius && box.Minimum.Y + radius <= sphere.Center.Y && \r
-                       sphere.Center.Y <= box.Maximum.Y - radius && box.Maximum.Y - box.Minimum.Y > radius && \r
-                       box.Minimum.Z + radius <= sphere.Center.Z && sphere.Center.Z <= box.Maximum.Z - radius &&\r
-                       box.Maximum.X - box.Minimum.X > radius )\r
-                       return ContainmentType::Contains;\r
-\r
-               return ContainmentType::Intersects;\r
-       }\r
-\r
-       ContainmentType BoundingBox::Contains( BoundingBox box, Vector3 vector )\r
-       {\r
-               if( box.Minimum.X <= vector.X && vector.X <= box.Maximum.X && box.Minimum.Y <= vector.Y && \r
-                       vector.Y <= box.Maximum.Y && box.Minimum.Z <= vector.Z && vector.Z <= box.Maximum.Z )\r
-                       return ContainmentType::Contains;\r
-\r
-               return ContainmentType::Disjoint;\r
-       }\r
-\r
-       BoundingBox BoundingBox::FromPoints( array<Vector3>^ points )\r
-       {\r
-               if( points == nullptr || points->Length <= 0 )\r
-                       throw gcnew ArgumentNullException( "points" );\r
-\r
-               Vector3 min = Vector3( float::MaxValue );\r
-               Vector3 max = Vector3( float::MinValue );\r
-\r
-               for each( Vector3 vector in points )\r
-               {\r
-                       Vector3::Minimize( min, vector, min );\r
-                       Vector3::Maximize( max, vector, max );\r
-               }\r
-\r
-               return BoundingBox( min, max );\r
-       }\r
-\r
-       BoundingBox BoundingBox::FromPoints( DataStream^ points, int count, int stride )\r
-       {\r
-               BoundingBox box;\r
-\r
-               HRESULT hr = D3DXComputeBoundingBox( reinterpret_cast<D3DXVECTOR3*>( points->PositionPointer ), count, stride, \r
-                       reinterpret_cast<D3DXVECTOR3*>( &box.Minimum ), reinterpret_cast<D3DXVECTOR3*>( &box.Maximum ) );\r
-\r
-               if( RECORD_SDX( hr ).IsFailure )\r
-                       return BoundingBox();\r
-\r
-               return box;\r
-       }\r
-\r
-       BoundingBox BoundingBox::FromSphere( BoundingSphere sphere )\r
-       {\r
-               BoundingBox box;\r
-               box.Minimum = Vector3( sphere.Center.X - sphere.Radius, sphere.Center.Y - sphere.Radius, sphere.Center.Z - sphere.Radius );\r
-               box.Maximum = Vector3( sphere.Center.X + sphere.Radius, sphere.Center.Y + sphere.Radius, sphere.Center.Z + sphere.Radius );\r
-               return box;\r
-       }\r
-\r
-       BoundingBox BoundingBox::Merge( BoundingBox box1, BoundingBox box2 )\r
-       {\r
-               BoundingBox box;\r
-               Vector3::Minimize( box1.Minimum, box2.Minimum, box.Minimum );\r
-               Vector3::Maximize( box1.Maximum, box2.Maximum, box.Maximum );\r
-               return box;\r
-       }\r
-\r
-       bool BoundingBox::Intersects( BoundingBox box1, BoundingBox box2 )\r
-       {\r
-               if ( box1.Maximum.X < box2.Minimum.X || box1.Minimum.X > box2.Maximum.X )\r
-                       return false;\r
-\r
-               if ( box1.Maximum.Y < box2.Minimum.Y || box1.Minimum.Y > box2.Maximum.Y )\r
-                       return false;\r
-\r
-               return ( box1.Maximum.Z >= box2.Minimum.Z && box1.Minimum.Z <= box2.Maximum.Z );\r
-       }\r
-\r
-       bool BoundingBox::Intersects( BoundingBox box, BoundingSphere sphere )\r
-       {\r
-               float dist;\r
-               Vector3 clamped;\r
-\r
-               Vector3::Clamp( sphere.Center, box.Minimum, box.Maximum, clamped );\r
-\r
-               float x = sphere.Center.X - clamped.X;\r
-               float y = sphere.Center.Y - clamped.Y;\r
-               float z = sphere.Center.Z - clamped.Z;\r
-\r
-               dist = (x * x) + (y * y) + (z * z);\r
-\r
-               return ( dist <= (sphere.Radius * sphere.Radius) );\r
-       }\r
-\r
-       bool BoundingBox::Intersects( BoundingBox box, Ray ray, [Out] float% distance )\r
-       {\r
-               return Ray::Intersects( ray, box, distance );\r
-       }\r
-\r
-       PlaneIntersectionType BoundingBox::Intersects( BoundingBox box, Plane plane )\r
-       {\r
-               return Plane::Intersects( plane, box );\r
-       }\r
-\r
-       bool BoundingBox::operator == ( BoundingBox left, BoundingBox right )\r
-       {\r
-               return BoundingBox::Equals( left, right );\r
-       }\r
-\r
-       bool BoundingBox::operator != ( BoundingBox left, BoundingBox right )\r
-       {\r
-               return !BoundingBox::Equals( left, right );\r
-       }\r
-\r
-       String^ BoundingBox::ToString()\r
-       {\r
-               return String::Format( CultureInfo::CurrentCulture, "Minimum:{0} Maximum:{1}", Minimum.ToString(), Maximum.ToString() );\r
-       }\r
-\r
-       int BoundingBox::GetHashCode()\r
-       {\r
-               return Minimum.GetHashCode() + Maximum.GetHashCode();\r
-       }\r
-\r
-       bool BoundingBox::Equals( Object^ value )\r
-       {\r
-               if( value == nullptr )\r
-                       return false;\r
-\r
-               if( value->GetType() != GetType() )\r
-                       return false;\r
-\r
-               return Equals( safe_cast<BoundingBox>( value ) );\r
-       }\r
-\r
-       bool BoundingBox::Equals( BoundingBox value )\r
-       {\r
-               return ( Minimum == value.Minimum && Maximum == value.Maximum );\r
-       }\r
-\r
-       bool BoundingBox::Equals( BoundingBox% value1, BoundingBox% value2 )\r
-       {\r
-               return ( value1.Minimum == value2.Minimum && value1.Maximum == value2.Maximum );\r
-       }\r
-}\r