Browse Source

Fixed Text3D in face camera mode becoming invisible after being out of the view frustum due to using old camera position.

Lasse Öörni 12 years ago
parent
commit
d26e2c148a
3 changed files with 7 additions and 4 deletions
  1. 2 1
      Engine/Graphics/Skybox.cpp
  2. 4 2
      Engine/UI/Text3D.cpp
  3. 1 1
      Engine/UI/Text3D.h

+ 2 - 1
Engine/Graphics/Skybox.cpp

@@ -35,7 +35,8 @@ namespace Urho3D
 OBJECTTYPESTATIC(Skybox);
 OBJECTTYPESTATIC(Skybox);
 
 
 Skybox::Skybox(Context* context) :
 Skybox::Skybox(Context* context) :
-    StaticModel(context)
+    StaticModel(context),
+    customWorldTransform_(Matrix3x4::IDENTITY)
 {
 {
 }
 }
 
 

+ 4 - 2
Engine/UI/Text3D.cpp

@@ -48,6 +48,7 @@ Text3D::Text3D(Context* context) :
     Drawable(context, DRAWABLE_GEOMETRY),
     Drawable(context, DRAWABLE_GEOMETRY),
     text_(context),
     text_(context),
     vertexBuffer_(new VertexBuffer(context_)),
     vertexBuffer_(new VertexBuffer(context_)),
+    customWorldTransform_(Matrix3x4::IDENTITY),
     faceCamera_(false),
     faceCamera_(false),
     textDirty_(true),
     textDirty_(true),
     geometryDirty_(true)
     geometryDirty_(true)
@@ -352,8 +353,9 @@ void Text3D::OnWorldBoundingBoxUpdate()
     if (textDirty_)
     if (textDirty_)
         UpdateTextBatches();
         UpdateTextBatches();
     
     
-    worldBoundingBox_ = faceCamera_ ? boundingBox_.Transformed(customWorldTransform_) :
-        boundingBox_.Transformed(node_->GetWorldTransform());
+    // In face camera mode, use the last camera rotation to build the world bounding box
+    worldBoundingBox_ = boundingBox_.Transformed(faceCamera_ ? Matrix3x4(node_->GetWorldPosition(),
+        customWorldTransform_.Rotation(), node_->GetWorldScale()) : node_->GetWorldTransform());
 }
 }
 
 
 void Text3D::MarkTextDirty()
 void Text3D::MarkTextDirty()

+ 1 - 1
Engine/UI/Text3D.h

@@ -157,7 +157,7 @@ private:
     PODVector<float> uiVertexData_;
     PODVector<float> uiVertexData_;
     /// Local-space bounding box.
     /// Local-space bounding box.
     BoundingBox boundingBox_;
     BoundingBox boundingBox_;
-    /// Custom world transform.
+    /// Custom world transform for facing the camera automatically.
     Matrix3x4 customWorldTransform_;
     Matrix3x4 customWorldTransform_;
     /// Face camera flag.
     /// Face camera flag.
     bool faceCamera_;
     bool faceCamera_;