void Camera::update_following(double dt) { ActorPtr following_actor = following_actor_.lock(); if(following_actor) { kmQuaternion actor_rotation = following_actor->absolute_rotation(); kmVec3 actor_position = following_actor->absolute_position(); kmVec3 actor_forward; kmQuaternionGetForwardVec3RH(&actor_forward, &actor_rotation); kmQuaternion initial_rotation; kmQuaternionAssign(&initial_rotation, &rotation_); float t = ((following_lag_ == 0) ? 1.0 : dt * (1.0 / following_lag_)); kmQuaternionSlerp(&rotation_, &initial_rotation, &actor_rotation, t); kmVec3 rotated_offset; kmQuaternionMultiplyVec3(&rotated_offset, &rotation_, &following_offset_); //kmMat4RotationQuaternion(&new_rotation_matrix, &rotation_); //kmVec3MultiplyMat4(&rotated_offset, &following_offset_, &new_rotation_matrix); kmVec3Add(&position_, &rotated_offset, &actor_position); update_from_parent(); } else { //The actor was destroyed, so reset following_actor_ = ActorRef(); } }
ActorRef IActor::Find(ActorSelector const& selector) const { if (selector(m_self.lock())) { return m_self; } for (auto&& child : m_children) { ActorRef&& find = child->Find(selector); if (!find.expired()) { return find; } } return ActorRef(); }
ActorRef TcpClient::create(const char* host, uint16_t port) { return ActorRef(new TcpClient(host, port)); }
ActorRef Splitter::create(ActorRef input) { return ActorRef(new Splitter(input)); }
ActorRef LineFramer::create(ActorRef link) { return ActorRef(new LineFramer(link)); }
//_____________________________________________________________ // ActorRef TcpServer::create(ActorRef wifi, uint16_t port) { return ActorRef(new TcpServer(wifi, port)); }
ActorRef Tcp::create() { return ActorRef(new Tcp()); }