|
|
@@ -25,6 +25,7 @@
|
|
|
#include "CollisionShape.h"
|
|
|
#include "Context.h"
|
|
|
#include "Log.h"
|
|
|
+#include "MemoryBuffer.h"
|
|
|
#include "PhysicsWorld.h"
|
|
|
#include "ResourceCache.h"
|
|
|
#include "ResourceEvents.h"
|
|
|
@@ -68,18 +69,19 @@ void RigidBody::RegisterObject(Context* context)
|
|
|
context->RegisterFactory<RigidBody>();
|
|
|
|
|
|
ATTRIBUTE(RigidBody, VAR_FLOAT, "Mass", mass_, DEFAULT_MASS, AM_DEFAULT);
|
|
|
- ACCESSOR_ATTRIBUTE(RigidBody, VAR_VECTOR3, "Physics Position", GetPosition, SetPosition, Vector3, Vector3::ZERO, AM_FILE);
|
|
|
- ACCESSOR_ATTRIBUTE(RigidBody, VAR_QUATERNION, "Physics Rotation", GetRotation, SetRotation, Quaternion, Quaternion::IDENTITY, AM_FILE);
|
|
|
+ ACCESSOR_ATTRIBUTE(RigidBody, VAR_VECTOR3, "Physics Position", GetPosition, SetPosition, Vector3, Vector3::ZERO, AM_FILE | AM_NOEDIT);
|
|
|
+ ACCESSOR_ATTRIBUTE(RigidBody, VAR_QUATERNION, "Physics Rotation", GetRotation, SetRotation, Quaternion, Quaternion::IDENTITY, AM_FILE | AM_NOEDIT);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_VECTOR3, "Linear Velocity", GetLinearVelocity, SetLinearVelocity, Vector3, Vector3::ZERO, AM_DEFAULT | AM_LATESTDATA);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_FLOAT, "Linear Rest Threshold", GetLinearRestThreshold, SetLinearRestThreshold, float, 0.01f, AM_DEFAULT);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_FLOAT, "Linear Damping Threshold", GetLinearDampingThreshold, SetLinearDampingThreshold, float, 0.01f, AM_DEFAULT);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_FLOAT, "Linear Damping Scale", GetLinearDampingScale, SetLinearDampingScale, float, 0.0f, AM_DEFAULT);
|
|
|
- ACCESSOR_ATTRIBUTE(RigidBody, VAR_VECTOR3, "Angular Velocity", GetAngularVelocity, SetAngularVelocity, Vector3, Vector3::ZERO, AM_DEFAULT | AM_LATESTDATA);
|
|
|
+ ACCESSOR_ATTRIBUTE(RigidBody, VAR_VECTOR3, "Angular Velocity", GetAngularVelocity, SetAngularVelocity, Vector3, Vector3::ZERO, AM_FILE);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_FLOAT, "Angular Rest Threshold", GetAngularRestThreshold, SetAngularRestThreshold, float, 0.01f, AM_DEFAULT);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_FLOAT, "Angular Damping Threshold", GetAngularDampingThreshold, SetAngularDampingThreshold, float, 0.01f, AM_DEFAULT);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_FLOAT, "Angular Damping Scale", GetAngularDampingScale, SetAngularDampingScale, float, 0.0f, AM_DEFAULT);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_FLOAT, "Angular Max Velocity", GetAngularMaxVelocity, SetAngularMaxVelocity, float, M_INFINITY, AM_DEFAULT);
|
|
|
ACCESSOR_ATTRIBUTE(RigidBody, VAR_BOOL, "Is Active", IsActive, SetActive, bool, true, AM_FILE);
|
|
|
+ REF_ACCESSOR_ATTRIBUTE(RigidBody, VAR_BUFFER, "Network Angular Velocity", GetNetAngularVelocityAttr, SetNetAngularVelocityAttr, PODVector<unsigned char>, PODVector<unsigned char>(), AM_NET | AM_LATESTDATA | AM_NOEDIT);
|
|
|
}
|
|
|
|
|
|
void RigidBody::SetMass(float mass)
|
|
|
@@ -333,6 +335,23 @@ bool RigidBody::IsActive() const
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+void RigidBody::SetNetAngularVelocityAttr(const PODVector<unsigned char>& value)
|
|
|
+{
|
|
|
+ float maxVelocity = physicsWorld_ ? physicsWorld_->GetMaxNetworkAngularVelocity() : DEFAULT_MAX_NETWORK_ANGULAR_VELOCITY;
|
|
|
+
|
|
|
+ MemoryBuffer buf(value);
|
|
|
+ SetAngularVelocity(buf.ReadPackedVector3(maxVelocity));
|
|
|
+}
|
|
|
+
|
|
|
+const PODVector<unsigned char>& RigidBody::GetNetAngularVelocityAttr() const
|
|
|
+{
|
|
|
+ float maxVelocity = physicsWorld_ ? physicsWorld_->GetMaxNetworkAngularVelocity() : DEFAULT_MAX_NETWORK_ANGULAR_VELOCITY;
|
|
|
+
|
|
|
+ attrBuffer_.Clear();
|
|
|
+ attrBuffer_.WritePackedVector3(GetAngularVelocity(), maxVelocity);
|
|
|
+ return attrBuffer_.GetBuffer();
|
|
|
+}
|
|
|
+
|
|
|
void RigidBody::OnMarkedDirty(Node* node)
|
|
|
{
|
|
|
// Clear the dirty flag by querying world position; this way we are sure to get the dirty notification immediately
|