当前位置: 首页>>代码示例>>C++>>正文


C++ Object::bound_box方法代码示例

本文整理汇总了C++中bl::Object::bound_box方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::bound_box方法的具体用法?C++ Object::bound_box怎么用?C++ Object::bound_box使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bl::Object的用法示例。


在下文中一共展示了Object::bound_box方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: object_boundbox_clip

/* TODO(sergey): Not really optimal, consider approaches based on k-DOP in order
 * to reduce number of objects which are wrongly considered visible.
 */
static bool object_boundbox_clip(Scene *scene,
                                 BL::Object& b_ob,
                                 Transform& tfm,
                                 float margin)
{
	Camera *cam = scene->camera;
	Transform& worldtondc = cam->worldtondc;
	BL::Array<float, 24> boundbox = b_ob.bound_box();
	float3 bb_min = make_float3(FLT_MAX, FLT_MAX, FLT_MAX),
	       bb_max = make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
	bool all_behind = true;
	for(int i = 0; i < 8; ++i) {
		float3 p = make_float3(boundbox[3 * i + 0],
		                       boundbox[3 * i + 1],
		                       boundbox[3 * i + 2]);
		p = transform_point(&tfm, p);

		float4 b = make_float4(p.x, p.y, p.z, 1.0f);
		float4 c = make_float4(dot(worldtondc.x, b),
		                       dot(worldtondc.y, b),
		                       dot(worldtondc.z, b),
		                       dot(worldtondc.w, b));
		p = float4_to_float3(c / c.w);
		if(c.z < 0.0f) {
			p.x = 1.0f - p.x;
			p.y = 1.0f - p.y;
		}
		if(c.z >= -margin) {
			all_behind = false;
		}
		bb_min = min(bb_min, p);
		bb_max = max(bb_max, p);
	}
	if(!all_behind) {
		if(bb_min.x >= 1.0f + margin ||
		   bb_min.y >= 1.0f + margin ||
		   bb_max.x <= -margin ||
		   bb_max.y <= -margin)
		{
			return true;
		}
		return false;
	}
	return true;
}
开发者ID:diekev,项目名称:blender,代码行数:48,代码来源:blender_object.cpp

示例2: test

bool BlenderObjectCulling::test(Scene *scene, BL::Object& b_ob, Transform& tfm)
{
	if(!use_camera_cull_ && !use_distance_cull_) {
		return false;
	}

	/* Compute world space bounding box corners. */
	float3 bb[8];
	BL::Array<float, 24> boundbox = b_ob.bound_box();
	for(int i = 0; i < 8; ++i) {
		float3 p = make_float3(boundbox[3 * i + 0],
		                       boundbox[3 * i + 1],
		                       boundbox[3 * i + 2]);
		bb[i] = transform_point(&tfm, p);
	}

	bool camera_culled = use_camera_cull_ && test_camera(scene, bb);
	bool distance_culled = use_distance_cull_ && test_distance(scene, bb);

	return ((camera_culled && distance_culled) ||
	        (camera_culled && !use_distance_cull_) ||
	        (distance_culled && !use_camera_cull_));
}
开发者ID:mgschwan,项目名称:blensor,代码行数:23,代码来源:blender_object_cull.cpp

示例3: object_boundbox_clip

/* TODO(sergey): Not really optimal, consider approaches based on k-DOP in order
 * to reduce number of objects which are wrongly considered visible.
 */
static bool object_boundbox_clip(Scene *scene,
                                 BL::Object b_ob,
                                 Transform& tfm,
                                 float margin)
{
	Camera *cam = scene->camera;
	Transform& worldtondc = cam->worldtondc;
	BL::Array<float, 24> boundbox = b_ob.bound_box();
	float3 bb_min = make_float3(FLT_MAX, FLT_MAX, FLT_MAX),
	       bb_max = make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX);
	bool all_behind = true;
	for(int i = 0; i < 8; ++i) {
		float3 p = make_float3(boundbox[3 * i + 0],
		                       boundbox[3 * i + 1],
		                       boundbox[3 * i + 2]);
		p = transform_point(&tfm, p);
		p = transform_point(&worldtondc, p);
		if(p.z >= -margin) {
			all_behind = false;
		}
		p /= p.z;
		bb_min = min(bb_min, p);
		bb_max = max(bb_max, p);
	}
	if(!all_behind) {
		if(bb_min.x >= 1.0f + margin ||
		   bb_min.y >= 1.0f + margin ||
		   bb_max.x <= -margin ||
		   bb_max.y <= -margin)
		{
			return true;
		}
		return false;
	}
	return true;
}
开发者ID:Moguri,项目名称:blender,代码行数:39,代码来源:blender_object.cpp


注:本文中的bl::Object::bound_box方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。