예제 #1
0
	double MaxMoveOnZclip(const AABB& boxA, const AABB& boxB, double movedist){
		//用boxA去撞boxB,别搞反了 (这好像还是句废话)
		if (!(inXclip(boxA, boxB) && inYclip(boxA, boxB))) return movedist;
		else if (boxA.zmin >= boxB.zmax && movedist < 0.0) return max(boxB.zmax - boxA.zmin, movedist);
		else if (boxA.zmax <= boxB.zmin && movedist > 0.0) return min(boxB.zmin - boxA.zmax, movedist);
		//assert(false);
		return !stuck ? movedist : 0.0;
	}
예제 #2
0
	double MaxMoveOnZclip(AABB boxA, AABB boxB, double movedist){
		//用boxA去撞boxB,别搞反了 (这好像还是句废话)
		double ret = 0.0;
		if (!(inXclip(boxA, boxB) && inYclip(boxA, boxB))){
			ret = movedist;
		}
		else if (boxA.zmin >= boxB.zmax && movedist < 0.00) {
			ret = boxB.zmax - boxA.zmin;
			if (ret<movedist) ret = movedist;
		}
		else if (boxA.zmax <= boxB.zmin && movedist > 0.0) {
			ret = boxB.zmin - boxA.zmax;
			if (ret > movedist) ret = movedist;
		}
		else{
			if (!stuck) ret = movedist;
			else ret = 0.0;
		}
		return ret;
	}
예제 #3
0
	bool Hit(AABB boxA, AABB boxB){
		return inXclip(boxA, boxB) && inYclip(boxA, boxB) && inZclip(boxA, boxB);
	}
예제 #4
0
	bool Hit(const AABB& boxA, const AABB& boxB){
		return inXclip(boxA, boxB) && inYclip(boxA, boxB) && inZclip(boxA, boxB);
	}
예제 #5
0
double AABB::maxMoveOnYclip(AABB target, double dist){
	if (!inXclip(target))return dist;
	if (ymin >= target.ymax && dist<0.0)return std::min(target.ymax - ymin, dist);
	if (ymax <= target.ymin && dist>0.0)return std::min(target.ymin - ymax, dist);
	return dist;
}
예제 #6
0
bool AABB::hitWith(AABB target){
	return inXclip(target) && inYclip(target);
}