Просмотр исходного кода

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

Lasse Öörni 12 лет назад
Родитель
Сommit
d26e2c148a
3 измененных файлов с 7 добавлено и 4 удалено
  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);
 
 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),
     text_(context),
     vertexBuffer_(new VertexBuffer(context_)),
+    customWorldTransform_(Matrix3x4::IDENTITY),
     faceCamera_(false),
     textDirty_(true),
     geometryDirty_(true)
@@ -352,8 +353,9 @@ void Text3D::OnWorldBoundingBoxUpdate()
     if (textDirty_)
         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()

+ 1 - 1
Engine/UI/Text3D.h

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