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


C++ Fvector::distance_to_sqr方法代码示例

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


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

示例1: closestPointOnTriangle

IC void closestPointOnTriangle(Fvector& result, const cl_tri& T, const Fvector& P) {
	Fvector Rab; closestPointOnEdge(Rab, T.p[0], T.p[1], T.e10, T.e10s, P); float dAB = P.distance_to_sqr(Rab);
	Fvector Rbc; closestPointOnEdge(Rbc, T.p[1], T.p[2], T.e21, T.e21s, P); float dBC = P.distance_to_sqr(Rbc);
	Fvector Rca; closestPointOnEdge(Rca, T.p[2], T.p[0], T.e02, T.e02s, P); float dCA = P.distance_to_sqr(Rca);
	
	float min;
	if (dBC < dAB)	{ min = dBC; result.set(Rbc); } 
	else			{ min = dAB; result.set(Rab); }
	if (dCA < min)	result.set(Rca);
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:10,代码来源:motion_simulator.cpp

示例2:

void CAI_Stalker::throw_target_impl			(const Fvector &position, CObject *throw_ignore_object )
{
	float					distance_to_sqr = position.distance_to_sqr(m_throw_target_position);
	m_throw_actual			= m_throw_actual && (distance_to_sqr < _sqr(.1f));
	m_throw_target_position	= position;
	m_throw_ignore_object	= throw_ignore_object;
}
开发者ID:zcaliptium,项目名称:xray-16,代码行数:7,代码来源:ai_stalker_fire.cpp

示例3:

IC float PLC_energy	(Fvector& P, Fvector& N, light* L, float E)
{
	Fvector Ldir;
	if (L->flags.type==IRender_Light::DIRECT)
	{
		// Cos
		Ldir.invert	(L->direction);
		float D		= Ldir.dotproduct( N );
		if( D <=0 )						return 0;
		
		// Trace Light
		float A		= D*E;
		return A;
	} else {
		// Distance
		float sqD	= P.distance_to_sqr(L->position);
		if (sqD > (L->range*L->range))	return 0;
		
		// Dir
		Ldir.sub	(L->position,P);
		Ldir.normalize_safe();
		float D		= Ldir.dotproduct( N );
		if( D <=0 )						return 0;
		
		// Trace Light
		float R		= _sqrt		(sqD);
		float att	= 1-(1/(1+R));
		float A		= D * E * att;
		return A;
	}
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:31,代码来源:LightShadows.cpp

示例4:

	void			_stab		(const AABBNoLeafNode* node)
	{
		// Actual ray/aabb test
		if (bUseSSE)			{
			// use SSE
			float		d;
			if (!_box_sse((Fvector&)node->mAABB.mCenter,(Fvector&)node->mAABB.mExtents,d))	return;
			if (d>rRange)																	return;
		} else {
			// use FPU
			Fvector		P;
			if (!_box_fpu((Fvector&)node->mAABB.mCenter,(Fvector&)node->mAABB.mExtents,P))	return;
			if (P.distance_to_sqr(ray.pos)>rRange2)											return;
		}
		
		// 1st chield
		if (node->HasLeaf())	_prim	(node->GetPrimitive());
		else					_stab	(node->GetPos());
		
		// Early exit for "only first"
		if (bFirst && dest->r_count())														return;
		
		// 2nd chield
		if (node->HasLeaf2())	_prim	(node->GetPrimitive2());
		else					_stab	(node->GetNeg());
	}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:26,代码来源:xrCDB_ray.cpp

示例5: clampr

IC int PLC_calc	(Fvector& P, Fvector& N, light* L, float energy, Fvector& O)
{
	float	E		= PLC_energy(P,N,L,energy);
	float	C1		= clampr(Device.vCameraPosition.distance_to_sqr(P)/S_distance2,	0.f,1.f);
	float	C2		= clampr(O.distance_to_sqr(P)/S_fade2,							0.f,1.f);
	float	A		= 1.f-1.5f*E*(1.f-C1)*(1.f-C2);
	return			iCeil(255.f*A);
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:8,代码来源:LightShadows.cpp

示例6:

void CWallmarksEngine::AddStaticWallmark	(CDB::TRI* pTri, const Fvector* pVerts, const Fvector &contact_point, ref_shader hShader, float sz)
{
	// optimization cheat: don't allow wallmarks more than 50 m from viewer/actor
	if (contact_point.distance_to_sqr(Device.vCameraPosition) > _sqr(100.f))	return;

	// Physics may add wallmarks in parallel with rendering
	lock.Enter				();
	AddWallmark_internal	(pTri,pVerts,contact_point,hShader,sz);
	lock.Leave				();
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:10,代码来源:WallmarksEngine.cpp

示例7: SpherePick

bool CSceneObject::SpherePick(const Fvector& center, float radius)
{
	if (!m_pReference) return false;
    float fR; Fvector vC;
	m_TBBox.getsphere(vC,fR);
	float R=radius+fR;
    float dist_sqr=center.distance_to_sqr(vC);
    if (dist_sqr<R*R) return true;
    return false;
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:10,代码来源:SceneObject.cpp

示例8:

IC float	SqrDistance2Segment(const Fvector& P, const Fvector& A, const Fvector& B)
{
	// Determine t (the length of the vector from ‘a’ to ‘p’)
	Fvector c; c.sub(P,A);
	Fvector V; V.sub(B,A); 
	
	float d = V.magnitude	();
	
	V.div	(d); 
	float t = V.dotproduct	(c);
	
	// Check to see if ‘t’ is beyond the extents of the line segment
	if (t <= 0.0f)	return P.distance_to_sqr(A);
	if (t >= d)		return P.distance_to_sqr(B);
	
	// Return the point between ‘a’ and ‘b’
	// set length of V to t. V is normalized so this is easy
	Fvector	R;	R.mad		(A,V,t);
	return P.distance_to_sqr(R);
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:20,代码来源:xrT_Junction.cpp

示例9: object

void CStalkerActionHideFromGrenade::execute					()
{
#ifdef TEST_MENTAL_STATE
	VERIFY								((start_level_time() == Device.dwTimeGlobal) || (object().movement().mental_state() == eMentalStateDanger));
#endif // TEST_MENTAL_STATE

	inherited::execute					();

	if (!object().memory().danger().selected())
		return;

	Fvector								position = object().memory().danger().selected()->position();
	const CCoverPoint					*point = object().best_cover(position);
	if (point) {
		setup_cover								(*point);
		object().movement().set_movement_type	(eMovementTypeRun);
	}
	else {
		object().movement().set_movement_type	(eMovementTypeStand);
		object().movement().set_body_state		(eBodyStateCrouch);
	}

	if (!object().memory().enemy().selected())
		object().sight().setup			(CSightAction(SightManager::eSightTypePathDirection,true,true));
	else {
		CMemoryInfo						mem_object = object().memory().memory(object().memory().enemy().selected());

		if (!mem_object.m_object) {
			object().sight().setup		(CSightAction(SightManager::eSightTypePathDirection,true,true));
			aim_ready					();
		}
		else {
			if (!m_object->memory().visual().visible_now(object().memory().enemy().selected())) {
				if (position.distance_to_sqr(object().Position()) < _sqr(5.f))
					object().sight().setup			(CSightAction(SightManager::eSightTypePathDirection,true,true));
				else
					object().sight().setup			(CSightAction(SightManager::eSightTypePosition,mem_object.m_object_params.m_position,true));

				aim_ready							();
			}
			else {
				object().sight().setup				(CSightAction(object().memory().enemy().selected(),true,true));
				fire								();
			}
		}
	}
	
	if (object().movement().path_completed())
		object().movement().set_body_state			(eBodyStateCrouch);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:50,代码来源:stalker_combat_actions.cpp

示例10:

	IC void		Perform	(u32 ID)
	{
		if (ID==InvalidNode)		return;
		if (ID>=q_Marks.size())		return;
		if (q_Marks[ID])			return;
		
		q_Marks[ID]			= true;
		q_Clear.push_back	(ID);

		vertex&	N			= g_nodes[ID];
		if (q_Base.distance_to_sqr(N.Pos)>cover_sqr_dist)	return;
		
		// ok
		q_List.push_back	(ID);
		
		Perform	(N.n1);
		Perform	(N.n2);
		Perform	(N.n3);
		Perform	(N.n4);
	}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:20,代码来源:compiler_cover.cpp

示例11: LightPoint

float LightPoint(CDB::COLLIDER& DB, Fvector &P, Fvector &N, LSelection& SEL)
{
    Fvector		Ldir,Pnew;
    Pnew.mad	(P,N,0.05f);

    R_Light	**IT = SEL.begin(), **E = SEL.end();

    float	amount = 0;
    for (; IT!=E; IT++)
    {
        R_Light* L = *IT;
        if (L->type==LT_DIRECT)
        {
            // Cos
            Ldir.invert	(L->direction);
            float D		= Ldir.dotproduct( N );
            if( D <=0 ) continue;

            // Raypick
            if (!RayPick(DB,Pnew,Ldir,1000.f,*L))	amount+=D*L->amount;
        } else {
            // Distance
            float sqD	= P.distance_to_sqr(L->position);
            if (sqD > L->range2) continue;

            // Dir
            Ldir.sub	(L->position,P);
            Ldir.normalize_safe();
            float D		= Ldir.dotproduct( N );
            if( D <=0 ) continue;

            // Raypick
            float R		= _sqrt(sqD);
            if (!RayPick(DB,Pnew,Ldir,R,*L))
                amount += (D*L->amount)/(L->attenuation0 + L->attenuation1*R + L->attenuation2*sqD);
        }
    }
    return amount;
}
开发者ID:Frankie-666,项目名称:xray-16,代码行数:39,代码来源:compiler_light.cpp

示例12: UpdateVisibleM

void CDetailManager::UpdateVisibleM()
{
	Fvector		EYE				= Device.vCameraPosition;
	CFrustum	View			= RImplementation.ViewBase;
	float fade_limit			= dm_fade;	fade_limit=fade_limit*fade_limit;
	float fade_start			= 1.f;		fade_start=fade_start*fade_start;
	float fade_range			= fade_limit-fade_start;
	float		r_ssaCHEAP		= 16*r_ssaDISCARD;

	// Initialize 'vis' and 'cache'
	// Collect objects for rendering
	Device.Statistic->RenderDUMP_DT_VIS.Begin	();
	for (int _mz=0; _mz<dm_cache1_line; _mz++){
		for (int _mx=0; _mx<dm_cache1_line; _mx++){
			CacheSlot1& MS		= cache_level1[_mz][_mx];
			if (MS.empty)		continue;
			u32 mask			= 0xff;
			u32 res				= View.testSAABB		(MS.vis.sphere.P,MS.vis.sphere.R,MS.vis.box.data(),mask);
			if (fcvNone==res)						 	continue;	// invisible-view frustum
			// test slots
			for (int _i=0; _i<dm_cache1_count*dm_cache1_count; _i++){
				Slot*	PS		= *MS.slots[_i];
				Slot& 	S 		= *PS;

				// if slot empty - continue
				if (S.empty)	continue;

				// if upper test = fcvPartial - test inner slots
				if (fcvPartial==res){
					u32 _mask	= mask;
					u32 _res	= View.testSAABB			(S.vis.sphere.P,S.vis.sphere.R,S.vis.box.data(),_mask);
					if (fcvNone==_res)						continue;	// invisible-view frustum
				}
#ifndef _EDITOR
				if (!RImplementation.HOM.visible(S.vis))	continue;	// invisible-occlusion
#endif
				// Add to visibility structures
				if (Device.dwFrame>S.frame){
					// Calc fade factor	(per slot)
					float	dist_sq		= EYE.distance_to_sqr	(S.vis.sphere.P);
					if		(dist_sq>fade_limit)				continue;
					float	alpha		= (dist_sq<fade_start)?0.f:(dist_sq-fade_start)/fade_range;
					float	alpha_i		= 1.f - alpha;
					float	dist_sq_rcp	= 1.f / dist_sq;

					S.frame			= Device.dwFrame+Random.randI(15,30);
					for (int sp_id=0; sp_id<dm_obj_in_slot; sp_id++){
						SlotPart&			sp	= S.G		[sp_id];
						if (sp.id==DetailSlot::ID_Empty)	continue;

						sp.r_items[0].clear_not_free();
						sp.r_items[1].clear_not_free();
						sp.r_items[2].clear_not_free();

						float				R		= objects	[sp.id]->bv_sphere.R;
						float				Rq_drcp	= R*R*dist_sq_rcp;	// reordered expression for 'ssa' calc

						SlotItem			**siIT=&(*sp.items.begin()), **siEND=&(*sp.items.end());
						for (; siIT!=siEND; siIT++){
							SlotItem& Item			= *(*siIT);
							float   scale			= Item.scale_calculated	= Item.scale*alpha_i;
							float	ssa				= scale*scale*Rq_drcp;
							if (ssa < r_ssaDISCARD) continue;
							u32		vis_id			= 0;
							if (ssa > r_ssaCHEAP)	vis_id = Item.vis_ID;
							
							sp.r_items[vis_id].push_back	(*siIT);

//2							visible[vis_id][sp.id].push_back(&Item);
						}
					}
				}
				for (int sp_id=0; sp_id<dm_obj_in_slot; sp_id++){
					SlotPart&			sp	= S.G		[sp_id];
					if (sp.id==DetailSlot::ID_Empty)	continue;
					if (!sp.r_items[0].empty()) visible[0][sp.id].push_back(&sp.r_items[0]);
					if (!sp.r_items[1].empty()) visible[1][sp.id].push_back(&sp.r_items[1]);
					if (!sp.r_items[2].empty()) visible[2][sp.id].push_back(&sp.r_items[2]);
				}
			}
		}
	}
	Device.Statistic->RenderDUMP_DT_VIS.End	();
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:84,代码来源:DetailManager.cpp

示例13:

	ICF bool	operator()		(const CDB::RESULT& _1, const CDB::RESULT& _2) const {
		occTri&	t0	= m_pTris	[_1.id];
		occTri&	t1	= m_pTris	[_2.id];
		return	camera.distance_to_sqr(t0.center) < camera.distance_to_sqr(t1.center);
	}
开发者ID:2asoft,项目名称:xray-16,代码行数:5,代码来源:HOM.cpp

示例14: CheckPointInSphere

// ----------------------------------------------------------------------
// Name  : CheckPointInSphere()
// Input : point - point we wish to check for inclusion
//         sO - Origin of sphere
//         sR - radius of sphere
// Notes :
// Return: TRUE if point is in sphere, FALSE if not.
// -----------------------------------------------------------------------
IC bool CheckPointInSphere(const Fvector& point, const Fvector& sO, float sR) {
    return (sO.distance_to_sqr(point)< sR*sR);
}
开发者ID:Frankie-666,项目名称:xray-16,代码行数:11,代码来源:motion_simulator.cpp

示例15:

void CAI_Stalker::throw_target				(const Fvector &position)
{
	float					distance_to_sqr = position.distance_to_sqr(m_throw_target);
	m_throw_actual			= m_throw_actual && (distance_to_sqr < _sqr(.1f));
	m_throw_target			= position;
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:6,代码来源:ai_stalker_fire.cpp


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