/*
 * @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));
}
示例#2
0
static void updateGrounded(cpBody* body, cpArbiter* arb, bool* grounded)
{
	cpVect n = cpArbiterGetNormal(arb, 0);
	if (n.y < 0)
	{
		*grounded = true;
	}
}
示例#3
0
static void
SelectPlayerGroundNormal(cpBody *body, cpArbiter *arb, cpVect *groundNormal){
	cpVect n = cpArbiterGetNormal(arb);
	
	if(n.y > groundNormal->y){
		(*groundNormal) = n;
	}
}
示例#4
0
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;
}
示例#5
0
文件: OneWay.c 项目: 0w/moai-dev
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;
}
示例#6
0
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;
}
示例#7
0
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;
}
示例#8
0
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;
}
示例#9
0
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;
}
示例#11
0
文件: wrapper.c 项目: Et999/Hipmunk
void wrArbiterGetNormal(cpArbiter *arb, cpVect *ret) {
    *ret = cpArbiterGetNormal(arb, 0);
}
示例#12
0
static int cpArbiter_getNormal(lua_State *L) {
    cpArbiter *arb = toarbiter(L);
    push_cpVect(L, cpArbiterGetNormal(arb, 0));
    return 2;
}
示例#13
0
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;
}