/* * Class: com_badlogic_gdx_physics_box2d_World * Method: jniCreateBody * Signature: (JIFFFFFFFFZZZZZF)J */ JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_physics_box2d_World_jniCreateBody (JNIEnv *, jobject, jlong addr, jint type, jfloat positionX, jfloat positionY, jfloat angle, jfloat linearVelocityX, jfloat linearVelocityY, jfloat angularVelocity, jfloat linearDamping, jfloat angularDamping, jboolean allowSleep, jboolean awake, jboolean fixedRotation, jboolean bullet, jboolean active, jfloat gravityScale) { b2BodyDef bodyDef; bodyDef.type = getBodyType(type); bodyDef.position.Set( positionX, positionY ); bodyDef.angle = angle; bodyDef.linearVelocity.Set( linearVelocityX, linearVelocityY ); bodyDef.angularVelocity = angularVelocity; bodyDef.linearDamping = linearDamping; bodyDef.angularDamping = angularDamping; bodyDef.allowSleep = allowSleep; bodyDef.awake = awake; bodyDef.fixedRotation = fixedRotation; bodyDef.bullet = bullet; bodyDef.active = active; bodyDef.gravityScale = gravityScale; b2World* world = (b2World*)addr; b2Body* body = world->CreateBody( &bodyDef ); //#ifdef ANDROID // __android_log_write(ANDROID_LOG_ERROR,"Tag","HIIII"); //#endif return (jlong)body; }
JNIEXPORT jlong JNICALL Java_com_badlogic_gdx_physics_box2d_World_jniCreateBody(JNIEnv* env, jobject object, jlong addr, jint type, jfloat positionX, jfloat positionY, jfloat angle, jfloat linearVelocityX, jfloat linearVelocityY, jfloat angularVelocity, jfloat linearDamping, jfloat angularDamping, jboolean allowSleep, jboolean awake, jboolean fixedRotation, jboolean bullet, jboolean active, jfloat inertiaScale) { //@line:284 b2BodyDef bodyDef; bodyDef.type = getBodyType(type); bodyDef.position.Set( positionX, positionY ); bodyDef.angle = angle; bodyDef.linearVelocity.Set( linearVelocityX, linearVelocityY ); bodyDef.angularVelocity = angularVelocity; bodyDef.linearDamping = linearDamping; bodyDef.angularDamping = angularDamping; bodyDef.allowSleep = allowSleep; bodyDef.awake = awake; bodyDef.fixedRotation = fixedRotation; bodyDef.bullet = bullet; bodyDef.active = active; bodyDef.gravityScale = inertiaScale; b2World* world = (b2World*)addr; b2Body* body = world->CreateBody( &bodyDef ); return (jlong)body; }
b2BodyDef Body::getBodyDef() { b2BodyDef bodyDef; if (!mBody) { // Default static properties bodyDef.type = static_cast<b2BodyType>(StaticBody); bodyDef.active = true; bodyDef.linearDamping = 0.0f; bodyDef.angularDamping = 0.0f; bodyDef.gravityScale = 1.0f; // Default dynamic properties bodyDef.linearVelocity = b2Vec2(0.0f, 0.0f); bodyDef.angularVelocity = 0.0f; } else { bodyDef.type = static_cast<b2BodyType>(getBodyType()); bodyDef.active = isActive(); bodyDef.linearDamping = getLinearDamping(); bodyDef.angularDamping = getAngularDamping(); bodyDef.gravityScale = getGravityScale(); bodyDef.linearVelocity = Box2dUtil::toB2Vec2(getLinearVelocity()); bodyDef.angularVelocity = getAngleInRadians(); } bodyDef.userData = this; return bodyDef; }
b2Body* NPC::createBody (const b2Vec2 &pos, bool setOnGround, bool fixedRotation) { if (!_bodies.empty()) { error(LOG_SERVER, "there are already bodies defined for this npc"); return nullptr; } b2BodyDef bodyDef; bodyDef.type = getBodyType(); bodyDef.position.Set(pos.x, pos.y); b2Body* body = _map.getWorld()->CreateBody(&bodyDef); b2PolygonShape dynamicBox; const b2Vec2& size = getSize(); dynamicBox.SetAsBox(size.x / 2.0f, size.y / 2.0f); b2FixtureDef fixtureDef; fixtureDef.shape = &dynamicBox; fixtureDef.density = getDensity(); fixtureDef.friction = 0.0f; fixtureDef.restitution = 0.0f; body->SetUserData(static_cast<void*>(this)); body->CreateFixture(&fixtureDef); body->SetFixedRotation(fixedRotation); addBody(body); if (setOnGround) { static const b2Vec2 unitdir(0, 1); const b2Vec2 end = pos + 1 * unitdir; SetOnGroundRayCastCallback c(this); _map.getWorld()->RayCast(&c, pos, end); setPos(pos); } _initialPosition = pos; return body; }
JNIEXPORT void JNICALL Java_com_badlogic_gdx_physics_box2d_Body_jniSetType(JNIEnv* env, jobject object, jlong addr, jint type) { //@line:632 b2Body* body = (b2Body*)addr; body->SetType(getBodyType(type)); }
void Body::updateAfterPhysics() { // Don't update inactive or static bodies, as they can't possibly have moved as a result of // internal physics updates. Setting Actor position and transform fires off a bunch of signals // and invalidates internal state, which can get expensive. if (!isActive() || getBodyType() == StaticBody) { return; } Actor* actor = getActor(); if (actor) { actor->setPosition(getPosition()); actor->setRotation(qRadiansToDegrees(getAngleInRadians())); } }
void SIPB2BTransactionManager::onProcessResponseBody( SIPMessage::Ptr& pRequest, SIPB2BTransaction::Ptr pTransaction) { SIPB2BHandler::Ptr pHandler = findHandler(getBodyType(pRequest)); if (pHandler) { return pHandler->onProcessResponseBody(pRequest, pTransaction); } else if (_pDefaultHandler) { return _pDefaultHandler->onProcessResponseBody(pRequest, pTransaction); } }
JNIEXPORT void JNICALL Java_com_guidebee_game_physics_Body_jniSetType(JNIEnv* env, jobject object, jlong addr, jint type) { b2Body* body = (b2Body*)addr; body->SetType(getBodyType(type)); }