OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SSE2/Single/OgreArraySphere.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __SSE2_ArraySphere_H__
29 #define __SSE2_ArraySphere_H__
30 
31 #ifndef __ArraySphere_H__
32  #error "Don't include this file directly. include Math/Array/OgreArraySphere.h"
33 #endif
34 
35 #include "OgreSphere.h"
36 
37 #include "Math/Array/OgreMathlib.h"
39 
40 namespace Ogre
41 {
58  class _OgreExport ArraySphere
59  {
60  public:
61  ArrayReal mRadius;
62  ArrayVector3 mCenter;
63 
65  {
66  }
67 
68  ArraySphere( const ArrayReal &radius, const ArrayVector3 &center ) :
69  mRadius( radius ),
70  mCenter( center )
71  {
72  }
73 
74  void getAsSphere( Sphere &out, size_t index ) const
75  {
76  //Be careful of not writing to these regions or else strict aliasing rule gets broken!!!
77  const Real *aliasedRadius = reinterpret_cast<const Real*>( &mRadius );
78 
79  Vector3 center;
80  mCenter.getAsVector3( center, index );
81  out.setCenter( center );
82  out.setRadius( *aliasedRadius );
83  }
84 
87  Sphere getAsSphere( size_t index ) const
88  {
89  Sphere retVal;
90  getAsSphere( retVal, index );
91  return retVal;
92  }
93 
94  void setFromSphere( const Sphere &sphere, size_t index )
95  {
96  Real *aliasedRadius = reinterpret_cast<Real*>( &mRadius );
97  aliasedRadius[index] = sphere.getRadius();
98  mCenter.setFromVector3( sphere.getCenter(), index );
99  }
100 
102  void setAll( const Sphere &sphere )
103  {
104  const Real fRadius = sphere.getRadius();
105  const Vector3 &center = sphere.getCenter();
106  mRadius = _mm_set_ps1( fRadius );
107  mCenter.mChunkBase[0] = _mm_set_ps1( center.x );
108  mCenter.mChunkBase[1] = _mm_set_ps1( center.y );
109  mCenter.mChunkBase[2] = _mm_set_ps1( center.z );
110  }
111 
113  inline ArrayReal intersects( const ArraySphere &s ) const;
114 
116  inline ArrayReal intersects( const ArrayAabb &aabb ) const;
117 
119  inline ArrayReal intersects( const ArrayVector3 &v ) const;
120  };
124 }
125 
126 #include "OgreArraySphere.inl"
127 
128 #endif
const Vector3 & getCenter(void) const
Returns the center point of the sphere.
Definition: OgreSphere.h:73
void getAsSphere(Sphere &out, size_t index) const
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
void setFromSphere(const Sphere &sphere, size_t index)
Real ArrayReal
void setCenter(const Vector3 &center)
Sets the center point of the sphere.
Definition: OgreSphere.h:76
Cache-friendly array of 3-dimensional represented as a SoA array.
Sphere getAsSphere(size_t index) const
Prefer using.
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Real getRadius(void) const
Returns the radius of the sphere.
Definition: OgreSphere.h:67
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
Cache-friendly array of Sphere represented as a SoA array.
void setRadius(Real radius)
Sets the radius of the sphere.
Definition: OgreSphere.h:70
ArraySphere(const ArrayReal &radius, const ArrayVector3 &center)
Cache-friendly array of Aabb represented as a SoA array.
void setAll(const Sphere &sphere)
Sets all packed spheres to the same value as the scalar input sphere.