예제 #1
0
파일: MapBlock.cpp 프로젝트: DragoonX6/R3E
void MapBlock::QuadIntersectRay(const QuadTree::Node* node, const Ray& ray, float& tMin) const {
	if(!node->IsVisible()) return;
	if(!ray.IntersectsBox(node->mBoundingBox)) return;
	if(!node->mChildren[0]){
		GetPatchIntersect(node->mIndex, ray, tMin);
		return;
	}

	QuadIntersectRay(node->mChildren[0], ray, tMin);
	QuadIntersectRay(node->mChildren[1], ray, tMin);
	QuadIntersectRay(node->mChildren[2], ray, tMin);
	QuadIntersectRay(node->mChildren[3], ray, tMin);

	return;
}
예제 #2
0
void SceneManager::MouseMove(int x, int y, int /*flags*/){
	Vector2 wnd = Vector2(float(mWidth), float(mHeight));
	Vector3 mouse = Vector3(float(x), float(mHeight - y), 0.0f);

	mHoverEntity = 0;

	if(!mEntityFlag[ENTITY_CAN_HOVER_IDX].Size()) return;
	Array<Entity*, 10>& lst = mEntityFlag[ENTITY_CAN_HOVER_IDX];

	Ray ray = UnprojectRay(mouse, mCamera->GetTransform(), mCamera->GetProjection(), wnd);
	Vector3 camPos = mCamera->GetTransform().TransformCoord(Vector3(0.0f, 0.0f, 0.0f));
	float nearest = 9999.0f;
	float dist;
	for(unsigned int i = 0; i < lst.Size(); ++i){
		Entity* entity = lst[i];
		if(!entity->mVisible) continue;
		if(!ray.IntersectsBox(entity->GetBoundingBox(), dist)) continue;
		if(dist > nearest) continue;
		nearest = dist;
		mHoverEntity = entity;
	}
}
예제 #3
0
파일: Entity.hpp 프로젝트: DragoonX6/R3E
	virtual bool CastRay(const Ray& ray, Vector3& out, float maxLengthSq){
		if(!ray.IntersectsBox(mBoundingBoxTransformed)) return false;
		return true;
	}