void PhysicsNode::readXml(const Xml *xml) { Node::readXml(xml); float mass = 0.0f; int body_type = BODY_BOX; xml->getChildData("body", body_type); xml->getChildData("mass", mass); xml->getChildData("render_body", render_body); xml->getChildData("object_2d", object_2d); body->setBody(BodyType(body_type)); body->setMass(mass); const Xml *transform = xml->getChild("init_transform"); if (transform != NULL) { transform->getArg("pos", init_pos); transform->getArg("rot", init_rot); transform->getArg("scale", init_scale); do_invalidate_matrix = false; setPos(init_pos); setRot(init_rot); setScale(init_scale); do_invalidate_matrix = true; invalidateMatrix(); } invalidate(); }
void PhysicsBodyComponent::update(double time) { if (BodyType() != BodyTypeEnum::STATIC) { b2Vec2 position = body_->GetPosition(); float angle = body_->GetAngle(); auto transform(get_user()->Transform.get()); math::set_rotation(transform, angle); math::set_translation(transform, position.x, position.y); get_user()->Transform.set(transform); get_user()->update_world_transform(); } Sleep.set_with_no_emit(!body_->IsAwake()); }
void initialize(pointVec_t &points) { //This function generate the same series of point on every call. //Reproducibility is needed for benchmarking to produce reliable results. //It is achieved through the following points: // - FillRNDPointsVector_buf instance has its own local instance // of random number generator, which in turn does not use any global data // - tbb::simple_partitioner produce the same set of ranges on every call to // tbb::parallel_for // - local RNG instances are seeded by the starting indexes of corresponding ranges // - grow_to_at_least() enables putting points into the resulting vector in deterministic order // (unlike concurrent push_back or grow_by). // In the buffered version, a temporary storage for as much as grainSize elements // is allocated inside the body. Since auto_partitioner may increase effective // range size which would cause a crash, simple partitioner has to be used. tbb::parallel_for(range_t(0, cfg::numberOfPoints, BodyType::grainSize), BodyType(points), tbb::simple_partitioner()); }
DrawGame::BodyType Body::getBodyType() const { return BodyType(bodyType.get()); }