mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Work around #16221 by updating parent chains
This commit is contained in:
parent
26aab6ecf2
commit
613ba689ff
2 changed files with 25 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <ICameraSceneNode.h>
|
#include <ICameraSceneNode.h>
|
||||||
#include <IMeshManipulator.h>
|
#include <IMeshManipulator.h>
|
||||||
#include <IAnimatedMeshSceneNode.h>
|
#include <IAnimatedMeshSceneNode.h>
|
||||||
|
#include <ISceneNode.h>
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
#include "client/renderingengine.h"
|
#include "client/renderingengine.h"
|
||||||
#include "client/sound.h"
|
#include "client/sound.h"
|
||||||
|
@ -343,6 +344,18 @@ bool GenericCAO::getSelectionBox(aabb3f *toset) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericCAO::updateParentChain() const
|
||||||
|
{
|
||||||
|
if (!m_matrixnode)
|
||||||
|
return;
|
||||||
|
// Update the entire chain of nodes to ensure absolute position is correct
|
||||||
|
std::vector<scene::ISceneNode *> chain;
|
||||||
|
for (scene::ISceneNode *node = m_matrixnode; node; node = node->getParent())
|
||||||
|
chain.push_back(node);
|
||||||
|
for (auto it = chain.rbegin(); it != chain.rend(); ++it)
|
||||||
|
(*it)->updateAbsolutePosition();
|
||||||
|
}
|
||||||
|
|
||||||
const v3f GenericCAO::getPosition() const
|
const v3f GenericCAO::getPosition() const
|
||||||
{
|
{
|
||||||
if (!getParent())
|
if (!getParent())
|
||||||
|
@ -350,6 +363,11 @@ const v3f GenericCAO::getPosition() const
|
||||||
|
|
||||||
// Calculate real position in world based on MatrixNode
|
// Calculate real position in world based on MatrixNode
|
||||||
if (m_matrixnode) {
|
if (m_matrixnode) {
|
||||||
|
// FIXME work around #16221 which is caused by the camera position and thus
|
||||||
|
// offset not being in sync with the player (parent) CAO position.
|
||||||
|
// A better solution might restrict this update to the local player only
|
||||||
|
// or keep player and camera position in sync.
|
||||||
|
GenericCAO::updateParentChain();
|
||||||
v3s16 camera_offset = m_env->getCameraOffset();
|
v3s16 camera_offset = m_env->getCameraOffset();
|
||||||
return m_matrixnode->getAbsolutePosition() +
|
return m_matrixnode->getAbsolutePosition() +
|
||||||
intToFloat(camera_offset, BS);
|
intToFloat(camera_offset, BS);
|
||||||
|
|
|
@ -149,6 +149,7 @@ private:
|
||||||
bool visualExpiryRequired(const ObjectProperties &newprops) const;
|
bool visualExpiryRequired(const ObjectProperties &newprops) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GenericCAO(Client *client, ClientEnvironment *env);
|
GenericCAO(Client *client, ClientEnvironment *env);
|
||||||
|
|
||||||
~GenericCAO();
|
~GenericCAO();
|
||||||
|
@ -299,4 +300,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMeshCulling();
|
void updateMeshCulling();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/// Update the parent chain so getPosition() returns an up to date position.
|
||||||
|
void updateParentChain() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue