OGRE 2.1 includes changes to objects, scenes, and nodes including:
1) IDs are now optional and uniqueness is determined by IdObject::getId() instead of names. Entities and movable objects will not share the same ID.
2) Debug object data is stored in a structure of arrays format and MovableObject::mObjectData stores the SoA data including packed index and parent pointers.
3) Movable objects like entities and lights now require being attached to scene nodes, and scene node static/dynamic flags impact transform and bounds updating for performance.
2. ID Uniqueness
Names are now optional (no need to be unique).
Identify uniqueness via IdObject::getId().
Entities/MovableObjects will not share the same ID.
Entity may share the same ID with scene node.
3. Debug Object Data
Data is stored in SoA (structure of arrays).
How 4 vectors are packed:
OGRE_USE_SIMD = 0 for C version array (debug purpose).
MovableObject::mObjectData for SoA data.
mIndex (0~3), packed index in SoA.
mParents: parents for packed 4 MovableObejcts.
4. Interpret ArrayVector3
mIndex order in m_chunkBase is right to left.
ArrayVector3 packs 4 vectors (ARRAY_PACKED_REALS = 4)
m_chunkBase: {mIndex=3, mIndex=2, mIndex=1, mIndex=0}
If 4 nodes created A, B, C, D.
Pack dummy pointer instead NULL.
MovableObject::mObjectData::mParents, Transform::mParents, …
Avoid null pointer checking.
5. Attachment and Visibility
OGRE 1.x:
Scene hierarchy traversal is expensive.
Objects were in the scene when being attached to scene
nodes.
OGRE 2.x:
Objects always in the scene, being attached to nodes to
hold their positions.
Detach object (entity) from node, will call setVisible(false)
implicitly. Previous visibility is lost. Call setVisible(true) while
detached will crash!
Optimized scene updates and iterations. Attach/detach
becomes more expensive. Call setVisible() for
hiding/showing objects.
6. MovableObject Require
SceneNode
MovableObjects (Entity, Light, Camera) require
being attached to SceneNodes.
No nodeless lights anymore. Light::setDirection() redirect to
SceneNode (fail if not attached).
Camera however have its own position and rotation (avoid
breaking old coder). Default camera is attached to the root
scene node. Need call Camera::detachFromParent() before
attaching camera to SceneNode manually.
7. Derived Transform
In 1.x, call SceneNode::_getDerivedPosition(), OGRE
keep flags to check if derived transform is dirty.
In 2.x, flags are removed for performance sake,
return cached derived transform.
The following won’t work.
SceneManager::updateAllTransforms() efficiently
update all, then cached derived transforms are
updated.
APIs force updating derived transform (including
all parents, slow!).
8. SCENE_STATIC and
SCENE_DYNAMIC
MovableObject/Node creation as static or dynamic.
Static means no move, rotation, scaling (or infrequently); save CPU
performance.
Default = dynamic.
SCENE_STATIC Node: no transform update.
SceneManager::notifyStaticDirty( scenenode ) to issue static node
update (recursively).
Dynamic node as child of static node (fit OGRE design); static node as
child of dynamic node may be a bug.
SCENE_STATIC Entity: no AABB bounds update (for culling).
SceneManager::notifyStaticDirty(entity) will update AABB, or when
attached Node is flagged as dirty.
9. Scene General Case
Static entity for static node only; dynamic entity for
dynamic node only.
Entity, Node can switch dynamic/static
(InstancedEntity cannot).
Destroy and recreate a new InstancedEntity instead.
SceneNode::setStatic() force all attached MovableObjects to
change concurrently.
Call setStatic(), change false to true, will call
notifyStaticDirty() implicitly.
Change static = true, can gain performance bump (no
transform & AABB update, and culling is much faster than
v1.x); batch counts remain the same.
10. Debug Mode Assertion
When AABB/transform is out of date, and
attempted to be used, OGRE issue assertion.
Solutions:
Static objects, do changes with notifyStaticDirty().
Avoid changes after SceneManager::updateAllTransforms()
or SceneManager::updateAllBounds().
Call Node::_getFullTransformUpdated() or
MovableObject::getWorldAabbUpdate(), be careful about
performance drop.
OGRE may also have bugs. Σ(;゚д゚), fire bug issues to them.
11. Renderable,
MovableObject subclass
In OGRE 1.x, allows add only Renderable objects
into render queues.
In OGRE 2.x, one Renderable MUST have one
MovableObject.
Visitor pattern for iterating MovableObject from Renderable
is removed, due to performance issue.
MovableObject subclasses must populate member,
MovableObject::mRenderables.
13. Vertex Element
Element offset, index, and total size can be
calculated.
VaoManager::calculateVertexSize(const
VertexElement2Vec&).
14. Too Dark?
PBS (physically based shading) expects gamma
correction.
Materials for PBS need serious adjustment. High Fresnel,
roughness can affect diffuse a lot. Textures also need to be
tweaked.
Color (1.0, 1.0, 1.0) means incredibly bright.
PBS works best with HDR (high dynamic range rendering).
Light::setPowerScale( 3.14) to compensate in LDR case.
External GUI texture may need gamma correction manually.
Activate gamma correction (default).