mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
make thread-safe
This commit is contained in:
parent
b990681b1a
commit
89f4ff426b
@ -36,9 +36,6 @@ get_joint() const {
|
||||
INLINE void JointVertexTransform::
|
||||
check_matrix() const {
|
||||
if (_matrix_stale) {
|
||||
((JointVertexTransform *)this)->_matrix =
|
||||
_joint->_initial_net_transform_inverse *
|
||||
_joint->_net_transform;
|
||||
((JointVertexTransform *)this)->_matrix_stale = false;
|
||||
((JointVertexTransform *)this)->compute_matrix();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "datagramIterator.h"
|
||||
#include "bamReader.h"
|
||||
#include "bamWriter.h"
|
||||
#include "mutexHolder.h"
|
||||
|
||||
TypeHandle JointVertexTransform::_type_handle;
|
||||
|
||||
@ -133,6 +134,20 @@ output(ostream &out) const {
|
||||
out << _joint->get_name();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: JointVertexTransform::compute_matrix
|
||||
// Access: Private
|
||||
// Description: Recomputes _matrix if it needs it. Uses locking.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void JointVertexTransform::
|
||||
compute_matrix() {
|
||||
MutexHolder holder(_lock);
|
||||
if (_matrix_stale) {
|
||||
_matrix = _joint->_initial_net_transform_inverse * _joint->_net_transform;
|
||||
_matrix_stale = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: JointVertexTransform::register_with_read_factory
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "characterJoint.h"
|
||||
#include "vertexTransform.h"
|
||||
#include "pointerTo.h"
|
||||
#include "pmutex.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : JointVertexTransform
|
||||
@ -56,11 +57,13 @@ PUBLISHED:
|
||||
|
||||
private:
|
||||
INLINE void check_matrix() const;
|
||||
void compute_matrix();
|
||||
|
||||
PT(CharacterJoint) _joint;
|
||||
|
||||
LMatrix4f _matrix;
|
||||
bool _matrix_stale;
|
||||
Mutex _lock;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
Loading…
x
Reference in New Issue
Block a user