/* ============ idScriptObject::GetFunction ============ */ const sdProgram::sdFunction* idScriptObject::GetFunction( const char *name ) const { if ( !HasObject() ) { return NULL; } return program->FindFunction( name, typeObject ); }
void Grabber::Update(q3Vec3 & lookAt, q3Vec3 & from){ if (HasObject()){ ApplyForce(lookAt, from); } else{ TryGrab(lookAt, from); } }
bool Animation::HasSameObjects(Animation const & animation) const { TAnimObjects const & objects = animation.GetObjects(); for (auto const & object : objects) { if (HasObject(object)) return true; } return false; }
bool HamurWorld::AddObject(HamurObject* newObject) { // Look in the map if the object is already added. If not found, then add. if(HasObject(newObject->GetName())) { HAMURLOG->WriteLogln("Warning: Object name already exists: " + newObject->GetName()); return false; } mWorldObjects[newObject->GetName()] = newObject; return true; }
void Grabber::ApplyForce(q3Vec3 & lookAt, q3Vec3 & from){ assert(HasObject()); #if GRABBER_USE_FORCE q3Vec3 objectPoint = mObject->GetWorldPoint(mPoint); q3Vec3 force = (from + (lookAt * mCallback.mData.t)) - objectPoint; // Also integrate the error over time mIntegralError += force * 0.1; r32 distance = q3Distance({0,0,0},force); q3Vec3 velocity = mObject->GetLinearVelocity(); if (q3Dot(velocity, force) < 0.0f){ // If the object is moving away from us, damp its velocity mObject->SetLinearVelocity(velocity * 0.95f); } // Always pull it very hard toward us force *= distance * distance; force += mIntegralError; mObject->ApplyForceAtWorldPoint(force, objectPoint); #else // THIS BUGS WITH STATIC OBJECTS auto tx = mObject->GetTransform(); tx.position = (from + (lookAt * mCallback.mData.t)); mObject->SetTransform(tx.position); auto v = mObject->GetLinearVelocity(); mObject->SetLinearVelocity(q3Vec3( 0, 0, 0 )); #endif }
bool HasProperty(TObject object, TProperty property) const override { return HasObject(object) && m_properties.find(property) != m_properties.end(); }
#include "parallel_animation.hpp" namespace df { ParallelAnimation::ParallelAnimation() : Animation(true /* couldBeInterrupted */, true /* couldBeBlended */) {} Animation::TObjectProperties const & ParallelAnimation::GetProperties(TObject object) const { ASSERT(HasObject(object), ()); return m_properties.find(object)->second; } bool ParallelAnimation::HasProperty(TObject object, TProperty property) const { if (!HasObject(object)) return false; TObjectProperties properties = GetProperties(object); return properties.find(property) != properties.end(); } void ParallelAnimation::AddAnimation(drape_ptr<Animation> animation) { TAnimObjects const & objects = animation->GetObjects(); m_objects.insert(objects.begin(), objects.end()); for (auto const & object : objects) { TObjectProperties const & properties = animation->GetProperties(object); m_properties[object].insert(properties.begin(), properties.end());
bool MapScaleAnimation::HasProperty(TObject object, TProperty property) const { return HasObject(object) && m_properties.find(property) != m_properties.end(); }
void Grabber::Throw(q3Vec3 & velocity){ if (HasObject()){ mObject->SetLinearVelocity(velocity); mObject = NULL; } }
void Grabber::Drop(){ if (HasObject()){ mObject = NULL; } }