vecidx_aos.h

Go to the documentation of this file.
00001 /*
00002    Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
00003    All rights reserved.
00004 
00005    Redistribution and use in source and binary forms,
00006    with or without modification, are permitted provided that the
00007    following conditions are met:
00008     * Redistributions of source code must retain the above copyright
00009       notice, this list of conditions and the following disclaimer.
00010     * Redistributions in binary form must reproduce the above copyright
00011       notice, this list of conditions and the following disclaimer in the
00012       documentation and/or other materials provided with the distribution.
00013     * Neither the name of the Sony Computer Entertainment Inc nor the names
00014       of its contributors may be used to endorse or promote products derived
00015       from this software without specific prior written permission.
00016 
00017    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027    POSSIBILITY OF SUCH DAMAGE.
00028 */
00029 
00030 #ifndef _VECTORMATH_VECIDX_AOS_H
00031 #define _VECTORMATH_VECIDX_AOS_H
00032 
00033 
00034 #include "floatInVec.h"
00035 
00036 namespace Vectormath {
00037 namespace Aos {
00038 
00039 //-----------------------------------------------------------------------------
00040 // VecIdx 
00041 // Used in setting elements of Vector3, Vector4, Point3, or Quat with the 
00042 // subscripting operator.
00043 //
00044 
00045 VM_ATTRIBUTE_ALIGNED_CLASS16 (class) VecIdx
00046 {
00047 private:
00048    __m128 &ref;
00049    int i;
00050 public:
00051     inline VecIdx( __m128& vec, int idx ): ref(vec) { i = idx; }
00052 
00053     // implicitly casts to float unless _VECTORMATH_NO_SCALAR_CAST defined
00054     // in which case, implicitly casts to floatInVec, and one must call
00055     // getAsFloat to convert to float.
00056     //
00057 #ifdef _VECTORMATH_NO_SCALAR_CAST
00058     inline operator floatInVec() const;
00059     inline float getAsFloat() const;
00060 #else
00061     inline operator float() const;
00062 #endif
00063 
00064     inline float operator =( float scalar );
00065     inline floatInVec operator =( const floatInVec &scalar );
00066     inline floatInVec operator =( const VecIdx& scalar );
00067     inline floatInVec operator *=( float scalar );
00068     inline floatInVec operator *=( const floatInVec &scalar );
00069     inline floatInVec operator /=( float scalar );
00070     inline floatInVec operator /=( const floatInVec &scalar );
00071     inline floatInVec operator +=( float scalar );
00072     inline floatInVec operator +=( const floatInVec &scalar );
00073     inline floatInVec operator -=( float scalar );
00074     inline floatInVec operator -=( const floatInVec &scalar );
00075 };
00076 
00077 } // namespace Aos
00078 } // namespace Vectormath
00079 
00080 #endif