Browse Source

Renamed GetData() to Data() in the Math library.
Set point light LightMatrices pixel shader parameter as 12 floats on Direct3D9.

Lasse Öörni 14 years ago
parent
commit
af7c5a53fb

+ 2 - 2
Engine/Graphics/AnimatedModel.cpp

@@ -266,13 +266,13 @@ void AnimatedModel::GetBatch(Batch& batch, const FrameInfo& frame, unsigned batc
         // Check if model has per-geometry bone mappings
         if (geometrySkinMatrices_.Size() && geometrySkinMatrices_[batchIndex].Size())
         {
-            batch.shaderData_ = geometrySkinMatrices_[batchIndex][0].GetData();
+            batch.shaderData_ = geometrySkinMatrices_[batchIndex][0].Data();
             batch.shaderDataSize_ = geometrySkinMatrices_[batchIndex].Size() * 12;
         }
         // If not, use the global skin matrices
         else
         {
-            batch.shaderData_ = skinMatrices_[0].GetData();
+            batch.shaderData_ = skinMatrices_[0].Data();
             batch.shaderDataSize_ = skinMatrices_.Size() * 12;
         }
     }

+ 14 - 8
Engine/Graphics/Batch.cpp

@@ -353,7 +353,7 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
                     for (unsigned i = 0; i < numSplits; ++i)
                         CalculateShadowMatrix(shadowMatrices[i], lightQueue_, i, renderer, Vector3::ZERO);
                     
-                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, shadowMatrices[0].GetData(), 16 * numSplits);
+                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, shadowMatrices[0].Data(), 16 * numSplits);
                 }
                 break;
                 
@@ -366,7 +366,7 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
                     if (isShadowed)
                         CalculateShadowMatrix(shadowMatrices[1], lightQueue_, 0, renderer, Vector3::ZERO);
                     
-                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, shadowMatrices[0].GetData(), isShadowed ? 32 : 16);
+                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, shadowMatrices[0].Data(), isShadowed ? 32 : 16);
                 }
                 break;
                 
@@ -376,9 +376,9 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
                     // HLSL compiler will pack the parameters as if the matrix is only 3x4, so must be careful to not overwrite
                     // the next parameter
                     #ifdef USE_OPENGL
-                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, lightVecRot.GetData(), 16);
+                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, lightVecRot.Data(), 16);
                     #else
-                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, lightVecRot.GetData(), 12);
+                    graphics->SetShaderParameter(VSP_LIGHTMATRICES, lightVecRot.Data(), 12);
                     #endif
                 }
                 break;
@@ -432,7 +432,7 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
             }
             
             if (lights.Size())
-                graphics->SetShaderParameter(VSP_VERTEXLIGHTS, vertexLights[0].GetData(), lights.Size() * 3 * 4);
+                graphics->SetShaderParameter(VSP_VERTEXLIGHTS, vertexLights[0].Data(), lights.Size() * 3 * 4);
         }
         
         if (graphics->NeedParameterUpdate(PSP_LIGHTCOLOR, light))
@@ -549,7 +549,7 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
                     for (unsigned i = 0; i < numSplits; ++i)
                         CalculateShadowMatrix(shadowMatrices[i], lightQueue_, i, renderer, camera_->GetWorldPosition());
                     
-                    graphics->SetShaderParameter(PSP_LIGHTMATRICES, shadowMatrices[0].GetData(), 16 * numSplits);
+                    graphics->SetShaderParameter(PSP_LIGHTMATRICES, shadowMatrices[0].Data(), 16 * numSplits);
                 }
                 break;
                 
@@ -562,14 +562,20 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
                     if (isShadowed)
                         CalculateShadowMatrix(shadowMatrices[1], lightQueue_, 0, renderer, camera_->GetWorldPosition());
                     
-                    graphics->SetShaderParameter(PSP_LIGHTMATRICES, shadowMatrices[0].GetData(), isShadowed ? 32 : 16);
+                    graphics->SetShaderParameter(PSP_LIGHTMATRICES, shadowMatrices[0].Data(), isShadowed ? 32 : 16);
                 }
                 break;
                 
             case LIGHT_POINT:
                 {
                     Matrix4 lightVecRot(light->GetWorldRotation().RotationMatrix());
-                    graphics->SetShaderParameter(PSP_LIGHTMATRICES, lightVecRot.GetData(), 16);
+                    // HLSL compiler will pack the parameters as if the matrix is only 3x4, so must be careful to not overwrite
+                    // the next parameter
+                    #ifdef USE_OPENGL
+                    graphics->SetShaderParameter(PSP_LIGHTMATRICES, lightVecRot.Data(), 16);
+                    #else
+                    graphics->SetShaderParameter(PSP_LIGHTMATRICES, lightVecRot.Data(), 12);
+                    #endif
                 }
                 break;
             }

+ 8 - 8
Engine/Graphics/Direct3D9/D3D9Graphics.cpp

@@ -1034,9 +1034,9 @@ void Graphics::SetShaderParameter(StringHash param, const Color& color)
         return;
     
     if (i->second_.type_ == VS)
-        impl_->device_->SetVertexShaderConstantF(i->second_.register_, color.GetData(), 1);
+        impl_->device_->SetVertexShaderConstantF(i->second_.register_, color.Data(), 1);
     else
-        impl_->device_->SetPixelShaderConstantF(i->second_.register_, color.GetData(), 1);
+        impl_->device_->SetPixelShaderConstantF(i->second_.register_, color.Data(), 1);
 }
 
 void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
@@ -1092,9 +1092,9 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
         return;
     
     if (i->second_.type_ == VS)
-        impl_->device_->SetVertexShaderConstantF(i->second_.register_, matrix.GetData(), 4);
+        impl_->device_->SetVertexShaderConstantF(i->second_.register_, matrix.Data(), 4);
     else
-        impl_->device_->SetPixelShaderConstantF(i->second_.register_, matrix.GetData(), 4);
+        impl_->device_->SetPixelShaderConstantF(i->second_.register_, matrix.Data(), 4);
 }
 
 void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
@@ -1104,9 +1104,9 @@ void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
         return;
     
     if (i->second_.type_ == VS)
-        impl_->device_->SetVertexShaderConstantF(i->second_.register_, vector.GetData(), 1);
+        impl_->device_->SetVertexShaderConstantF(i->second_.register_, vector.Data(), 1);
     else
-        impl_->device_->SetPixelShaderConstantF(i->second_.register_, vector.GetData(), 1);
+        impl_->device_->SetPixelShaderConstantF(i->second_.register_, vector.Data(), 1);
 }
 
 void Graphics::SetShaderParameter(StringHash param, const Matrix3x4& matrix)
@@ -1116,9 +1116,9 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix3x4& matrix)
         return;
     
     if (i->second_.type_ == VS)
-        impl_->device_->SetVertexShaderConstantF(i->second_.register_, matrix.GetData(), 3);
+        impl_->device_->SetVertexShaderConstantF(i->second_.register_, matrix.Data(), 3);
     else
-        impl_->device_->SetPixelShaderConstantF(i->second_.register_, matrix.GetData(), 3);
+        impl_->device_->SetPixelShaderConstantF(i->second_.register_, matrix.Data(), 3);
 }
 
 void Graphics::RegisterShaderParameter(StringHash param, const ShaderParameter& definition)

+ 10 - 10
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -899,7 +899,7 @@ void Graphics::SetShaderParameter(StringHash param, float value)
 
 void Graphics::SetShaderParameter(StringHash param, const Color& color)
 {
-    SetShaderParameter(param, color.GetData(), 4);
+    SetShaderParameter(param, color.Data(), 4);
 }
 
 void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
@@ -908,7 +908,7 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix3& matrix)
     {
         const ShaderParameter* info = shaderProgram_->GetParameter(param);
         if (info)
-            glUniformMatrix3fv(info->location_, 1, GL_TRUE, matrix.GetData());
+            glUniformMatrix3fv(info->location_, 1, GL_TRUE, matrix.Data());
     }
 }
 
@@ -923,15 +923,15 @@ void Graphics::SetShaderParameter(StringHash param, const Vector3& vector)
             switch (info->type_)
             {
             case GL_FLOAT:
-                glUniform1fv(info->location_, 1, vector.GetData());
+                glUniform1fv(info->location_, 1, vector.Data());
                 break;
                 
             case GL_FLOAT_VEC2:
-                glUniform2fv(info->location_, 1, vector.GetData());
+                glUniform2fv(info->location_, 1, vector.Data());
                 break;
                 
             case GL_FLOAT_VEC3:
-                glUniform3fv(info->location_, 1, vector.GetData());
+                glUniform3fv(info->location_, 1, vector.Data());
                 break;
             }
         }
@@ -944,7 +944,7 @@ void Graphics::SetShaderParameter(StringHash param, const Matrix4& matrix)
     {
         const ShaderParameter* info = shaderProgram_->GetParameter(param);
         if (info)
-            glUniformMatrix4fv(info->location_, 1, GL_TRUE, matrix.GetData());
+            glUniformMatrix4fv(info->location_, 1, GL_TRUE, matrix.Data());
     }
 }
 
@@ -959,19 +959,19 @@ void Graphics::SetShaderParameter(StringHash param, const Vector4& vector)
             switch (info->type_)
             {
             case GL_FLOAT:
-                glUniform1fv(info->location_, 1, vector.GetData());
+                glUniform1fv(info->location_, 1, vector.Data());
                 break;
                 
             case GL_FLOAT_VEC2:
-                glUniform2fv(info->location_, 1, vector.GetData());
+                glUniform2fv(info->location_, 1, vector.Data());
                 break;
                 
             case GL_FLOAT_VEC3:
-                glUniform3fv(info->location_, 1, vector.GetData());
+                glUniform3fv(info->location_, 1, vector.Data());
                 break;
                 
             case GL_FLOAT_VEC4:
-                glUniform4fv(info->location_, 1, vector.GetData());
+                glUniform4fv(info->location_, 1, vector.Data());
                 break;
             }
         }

+ 1 - 1
Engine/Graphics/OpenGL/OGLTexture.cpp

@@ -179,7 +179,7 @@ void Texture::UpdateParameters()
     else
         glTexParameteri(target_, GL_TEXTURE_COMPARE_MODE, GL_NONE);
     
-    glTexParameterfv(target_, GL_TEXTURE_BORDER_COLOR, borderColor_.GetData());
+    glTexParameterfv(target_, GL_TEXTURE_BORDER_COLOR, borderColor_.Data());
     
     parametersDirty_ = false;
 }

+ 1 - 1
Engine/Graphics/Skeleton.cpp

@@ -86,7 +86,7 @@ bool Skeleton::Save(Serializer& dest)
         dest.WriteVector3(bone.initialPosition_);
         dest.WriteQuaternion(bone.initialRotation_);
         dest.WriteVector3(bone.initialScale_);
-        dest.Write(bone.offsetMatrix_.GetData(), sizeof(Matrix3x4));
+        dest.Write(bone.offsetMatrix_.Data(), sizeof(Matrix3x4));
         
         // Collision info
         dest.WriteUByte(bone.collisionMask_);

+ 7 - 7
Engine/IO/Deserializer.cpp

@@ -122,28 +122,28 @@ IntRect Deserializer::ReadIntRect()
 IntVector2 Deserializer::ReadIntVector2()
 {
     IntVector2 ret;
-    Read((void*)ret.GetData(), sizeof ret);
+    Read((void*)ret.Data(), sizeof ret);
     return ret;
 }
 
 Rect Deserializer::ReadRect()
 {
     Rect ret;
-    Read((void*)ret.GetData(), sizeof ret);
+    Read((void*)ret.Data(), sizeof ret);
     return ret;
 }
 
 Vector2 Deserializer::ReadVector2()
 {
     Vector2 ret;
-    Read((void*)ret.GetData(), sizeof ret);
+    Read((void*)ret.Data(), sizeof ret);
     return ret;
 }
 
 Vector3 Deserializer::ReadVector3()
 {
     Vector3 ret;
-    Read((void*)ret.GetData(), sizeof ret);
+    Read((void*)ret.Data(), sizeof ret);
     return ret;
 }
 
@@ -163,14 +163,14 @@ Vector3 Deserializer::ReadPackedVector3(float maxAbsCoord)
 Vector4 Deserializer::ReadVector4()
 {
     Vector4 ret;
-    Read((void*)ret.GetData(), sizeof ret);
+    Read((void*)ret.Data(), sizeof ret);
     return ret;
 }
 
 Quaternion Deserializer::ReadQuaternion()
 {
     Quaternion ret;
-    Read((void*)ret.GetData(), sizeof ret);
+    Read((void*)ret.Data(), sizeof ret);
     return ret;
 }
 
@@ -191,7 +191,7 @@ Quaternion Deserializer::ReadPackedQuaternion()
 Color Deserializer::ReadColor()
 {
     Color ret;
-    Read((void*)ret.GetData(), sizeof ret);
+    Read((void*)ret.Data(), sizeof ret);
     return ret;
 }
 

+ 7 - 7
Engine/IO/Serializer.cpp

@@ -81,22 +81,22 @@ bool Serializer::WriteIntRect(const IntRect& value)
 
 bool Serializer::WriteIntVector2(const IntVector2& value)
 {
-    return Write(value.GetData(), sizeof value) == sizeof value;
+    return Write(value.Data(), sizeof value) == sizeof value;
 }
 
 bool Serializer::WriteRect(const Rect& value)
 {
-    return Write(value.GetData(), sizeof value) == sizeof value;
+    return Write(value.Data(), sizeof value) == sizeof value;
 }
 
 bool Serializer::WriteVector2(const Vector2& value)
 {
-    return Write(value.GetData(), sizeof value) == sizeof value;
+    return Write(value.Data(), sizeof value) == sizeof value;
 }
 
 bool Serializer::WriteVector3(const Vector3& value)
 {
-    return Write(value.GetData(), sizeof value) == sizeof value;
+    return Write(value.Data(), sizeof value) == sizeof value;
 }
 
 bool Serializer::WritePackedVector3(const Vector3& value, float maxAbsCoord)
@@ -112,12 +112,12 @@ bool Serializer::WritePackedVector3(const Vector3& value, float maxAbsCoord)
 
 bool Serializer::WriteVector4(const Vector4& value)
 {
-    return Write(value.GetData(), sizeof value) == sizeof value;
+    return Write(value.Data(), sizeof value) == sizeof value;
 }
 
 bool Serializer::WriteQuaternion(const Quaternion& value)
 {
-    return Write(value.GetData(), sizeof value) == sizeof value;
+    return Write(value.Data(), sizeof value) == sizeof value;
 }
 
 bool Serializer::WritePackedQuaternion(const Quaternion& value)
@@ -134,7 +134,7 @@ bool Serializer::WritePackedQuaternion(const Quaternion& value)
 
 bool Serializer::WriteColor(const Color& value)
 {
-    return Write(value.GetData(), sizeof value) == sizeof value;
+    return Write(value.Data(), sizeof value) == sizeof value;
 }
 
 bool Serializer::WriteBoundingBox(const BoundingBox& value)

+ 1 - 1
Engine/Math/Color.h

@@ -96,7 +96,7 @@ public:
     }
     
     /// Return float data.
-    const float* GetData() const { return &r_; }
+    const float* Data() const { return &r_; }
     /// Return RGB values as a Vector3.
     Vector3 RGBValues() const { return Vector3(r_, g_, b_); }
     /// Return approximate intensity.

+ 1 - 1
Engine/Math/Matrix3.h

@@ -229,7 +229,7 @@ public:
     Matrix3 Inverse() const;
     
     /// Return float data.
-    const float* GetData() const { return &m00_; }
+    const float* Data() const { return &m00_; }
     
     float m00_;
     float m01_;

+ 1 - 1
Engine/Math/Matrix3x4.h

@@ -359,7 +359,7 @@ public:
     Matrix3x4 Inverse() const;
     
     /// Return float data.
-    const float* GetData() const { return &m00_; }
+    const float* Data() const { return &m00_; }
     
     float m00_;
     float m01_;

+ 1 - 1
Engine/Math/Matrix4.h

@@ -399,7 +399,7 @@ public:
     Matrix4 Inverse() const;
     
     /// Return float data
-    const float* GetData() const { return &m00_; }
+    const float* Data() const { return &m00_; }
     
     float m00_;
     float m01_;

+ 1 - 1
Engine/Math/Quaternion.h

@@ -222,7 +222,7 @@ public:
     /// Spherical interpolation with another quaternion.
     Quaternion Slerp(Quaternion rhs, float t) const;
     /// Return float data.
-    const float* GetData() const { return &w_; }
+    const float* Data() const { return &w_; }
     /// Return as string.
     String ToString() const;
     

+ 1 - 1
Engine/Math/Rect.h

@@ -156,7 +156,7 @@ public:
     Vector2 HalfSize() const { return (max_ - min_) * 0.5f; }
     
     /// Return float data.
-    const void* GetData() const { return &min_.x_; }
+    const void* Data() const { return &min_.x_; }
     /// Return as string.
     String ToString() const;
     

+ 2 - 2
Engine/Math/Vector2.h

@@ -170,7 +170,7 @@ public:
     }
     
     /// Return float data.
-    const float* GetData() const { return &x_; }
+    const float* Data() const { return &x_; }
     /// Return as string.
     String ToString() const;
     
@@ -267,7 +267,7 @@ public:
     }
     
     /// Return integer data.
-    const int* GetData() const { return &x_; }
+    const int* Data() const { return &x_; }
     /// Return as string.
     String ToString() const;
     

+ 1 - 1
Engine/Math/Vector3.h

@@ -199,7 +199,7 @@ public:
     }
     
     /// Return float data.
-    const float* GetData() const { return &x_; }
+    const float* Data() const { return &x_; }
     /// Return as string.
     String ToString() const;
     

+ 1 - 1
Engine/Math/Vector4.h

@@ -170,7 +170,7 @@ public:
     Vector4 Lerp(const Vector4& rhs, float t) const { return *this * (1.0f - t) + rhs * t; }
     
     /// Return float data.
-    const float* GetData() const { return &x_; }
+    const float* Data() const { return &x_; }
     /// Return as string.
     String ToString() const;
     

+ 3 - 3
Engine/Physics/CollisionShape.cpp

@@ -592,7 +592,7 @@ void CollisionShape::UpdateTransform(bool nodeUpdate)
         {
             Vector3 offset(geometryScale_ * position_);
             dGeomSetOffsetPosition(geometry_, offset.x_, offset.y_, offset.z_);
-            dGeomSetOffsetQuaternion(geometry_, offsetQuaternion.GetData());
+            dGeomSetOffsetQuaternion(geometry_, offsetQuaternion.Data());
         }
         else
             dGeomClearOffset(geometry_);
@@ -608,7 +608,7 @@ void CollisionShape::UpdateTransform(bool nodeUpdate)
         Quaternion geomRot(nodeRot * offsetQuaternion);
         
         dGeomSetPosition(geometry_, geomPos.x_, geomPos.y_, geomPos.z_);
-        dGeomSetQuaternion(geometry_, geomRot.GetData());
+        dGeomSetQuaternion(geometry_, geomRot.Data());
     }
 }
 
@@ -632,7 +632,7 @@ void CollisionShape::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
     
     const Vector3& position = *reinterpret_cast<const Vector3*>(dGeomGetPosition(geometry_));
     Quaternion rotation;
-    dGeomGetQuaternion(geometry_, const_cast<float*>(rotation.GetData()));
+    dGeomGetQuaternion(geometry_, const_cast<float*>(rotation.Data()));
     Matrix3x4 transform(position, rotation, 1.0f);
     
     switch (dGeomGetClass(geometry_))

+ 6 - 6
Engine/Physics/RigidBody.cpp

@@ -112,7 +112,7 @@ void RigidBody::SetRotation(const Quaternion& rotation)
 {
     if (body_)
     {
-        dBodySetQuaternion(body_, rotation.GetData());
+        dBodySetQuaternion(body_, rotation.Data());
         previousRotation_ = rotation;
     }
 }
@@ -122,7 +122,7 @@ void RigidBody::SetTransform(const Vector3& position, const Quaternion& rotation
     if (body_)
     {
         dBodySetPosition(body_, position.x_, position.y_, position.z_);
-        dBodySetQuaternion(body_, rotation.GetData());
+        dBodySetQuaternion(body_, rotation.Data());
         previousPosition_ = position;
         previousRotation_ = rotation;
     }
@@ -379,7 +379,7 @@ void RigidBody::OnMarkedDirty(Node* node)
     {
         SetActive(true);
         dBodySetPosition(body_, newPosition.x_, newPosition.y_, newPosition.z_);
-        dBodySetQuaternion(body_, newRotation.GetData());
+        dBodySetQuaternion(body_, newRotation.Data());
         previousPosition_ = newPosition;
         previousRotation_ = newRotation;
     }
@@ -427,7 +427,7 @@ void RigidBody::PreStep()
         {
             SetActive(true);
             dBodySetPosition(body_, newPosition.x_, newPosition.y_, newPosition.z_);
-            dBodySetQuaternion(body_, newRotation.GetData());
+            dBodySetQuaternion(body_, newRotation.Data());
         }
     }
 }
@@ -500,7 +500,7 @@ void RigidBody::CreateBody()
         const Vector3& position = node_->GetTargetPosition();
         Quaternion rotation(node_->GetTargetRotation());
         dBodySetPosition(body_, position.x_, position.y_, position.z_);
-        dBodySetQuaternion(body_, rotation.GetData());
+        dBodySetQuaternion(body_, rotation.Data());
         previousPosition_ = position;
         previousRotation_ = rotation;
         
@@ -583,7 +583,7 @@ void RigidBody::UpdateMass()
         }
         
         dMatrix3 rotMatrix;
-        dRfromQ(rotMatrix, shape->GetRotation().GetData());
+        dRfromQ(rotMatrix, shape->GetRotation().Data());
         dMassTranslate(&subMass, offset.x_, offset.y_, offset.z_);
         dMassRotate(&subMass, rotMatrix);
         dMassAdd(&mass, &subMass);

+ 1 - 1
Tools/OgreImporter/OgreImporter.cpp

@@ -937,7 +937,7 @@ void WriteOutput(const String& outputFileName, bool exportAnimations, bool rotat
             
             Matrix3x4 offsetMatrix(bones_[i].derivedPosition_, bones_[i].derivedRotation_, bones_[i].derivedScale_);
             offsetMatrix = offsetMatrix.Inverse();
-            dest.Write(offsetMatrix.GetData(), sizeof(Matrix3x4));
+            dest.Write(offsetMatrix.Data(), sizeof(Matrix3x4));
             
             dest.WriteUByte(bones_[i].collisionMask_);
             if (bones_[i].collisionMask_ & 1)