/* * @param [Integer] i i-th contact point * @return [Chipmunk2d::Vect] */ static mrb_value arbiter_get_normal(mrb_state* mrb, mrb_value self) { cpArbiter* arbiter; arbiter = mrb_cp_get_arbiter_ptr(mrb, self); return mrb_cp_vect_value(mrb, cpArbiterGetNormal(arbiter)); }
static void updateGrounded(cpBody* body, cpArbiter* arb, bool* grounded) { cpVect n = cpArbiterGetNormal(arb, 0); if (n.y < 0) { *grounded = true; } }
static void SelectPlayerGroundNormal(cpBody *body, cpArbiter *arb, cpVect *groundNormal){ cpVect n = cpArbiterGetNormal(arb); if(n.y > groundNormal->y){ (*groundNormal) = n; } }
static cpBool PreSolve(cpArbiter *arb, cpSpace *space, void *ignore) { CP_ARBITER_GET_SHAPES(arb, a, b); OneWayPlatform *platform = (OneWayPlatform *)cpShapeGetUserData(a); if(cpvdot(cpArbiterGetNormal(arb), platform->n) < 0){ return cpArbiterIgnore(arb); } return cpTrue; }
static cpBool preSolve(cpArbiter *arb, cpSpace *space, void *ignore) { CP_ARBITER_GET_SHAPES(arb, a, b); OneWayPlatform *platform = (OneWayPlatform *)a->data; if(cpvdot(cpArbiterGetNormal(arb, 0), platform->n) < 0){ cpArbiterIgnore(arb); return cpFalse; } return cpTrue; }
static int begin(cpArbiter *arb, cpSpace *space, void *ignore) { CP_ARBITER_GET_SHAPES(arb, a, b); PlayerStruct *player = a->data; cpVect n = cpvneg(cpArbiterGetNormal(arb, 0)); if(n.y > 0.0f){ cpArrayPush(player->groundShapes, b); } return 1; }
static int preSolve(cpArbiter *arb, cpSpace *space, void *ignore) { CP_ARBITER_GET_SHAPES(arb, a, b); PlayerStruct *player = a->data; if(arb->stamp > 0){ a->u = player->u; // pick the most upright jump normal each frame cpVect n = cpvneg(cpArbiterGetNormal(arb, 0)); if(n.y >= player->groundNormal.y){ player->groundNormal = n; } } return 1; }
void PhysicsContact::generateContactData() { if (_contactInfo == nullptr) { return; } cpArbiter* arb = static_cast<cpArbiter*>(_contactInfo); CC_SAFE_DELETE(_preContactData); _preContactData = _contactData; _contactData = new (std::nothrow) PhysicsContactData(); _contactData->count = cpArbiterGetCount(arb); for (int i=0; i<_contactData->count && i<PhysicsContactData::POINT_MAX; ++i) { _contactData->points[i] = PhysicsHelper::cpv2point(cpArbiterGetPoint(arb, i)); } _contactData->normal = _contactData->count > 0 ? PhysicsHelper::cpv2point(cpArbiterGetNormal(arb, 0)) : Vec2::ZERO; }
cVect cArbiter::GetNormal( int i ) { return tovect( cpArbiterGetNormal( mArbiter, i ) ); }
JNIEXPORT jfloat JNICALL Java_com_wiyun_engine_chipmunk_Arbiter_getNormalY (JNIEnv * env, jobject thiz, jint contactIndex) { cpArbiter* arb = (cpArbiter*)env->GetIntField(thiz, g_fid_Arbiter_mPointer); cpVect v = cpArbiterGetNormal(arb, contactIndex); return v.y; }
void wrArbiterGetNormal(cpArbiter *arb, cpVect *ret) { *ret = cpArbiterGetNormal(arb, 0); }
static int cpArbiter_getNormal(lua_State *L) { cpArbiter *arb = toarbiter(L); push_cpVect(L, cpArbiterGetNormal(arb, 0)); return 2; }
int modArbiterGetNormal(INSTANCE * my, int * params){ cpVect v=cpArbiterGetNormal((cpArbiter *)params[0],params[1]); *(float*)params[2]=v.x; *(float*)params[3]=v.y; return 1; }