Example #1
0
void CPostprocessAnimator::SetCurrentFactor	(float f)					
{
	m_factor=f;
	m_dest_factor=f;
	VERIFY				(_valid(m_factor));
	VERIFY				(_valid(m_dest_factor));
};
void	CPHActivationShape::Create(const Fvector start_pos,const Fvector start_size,IPhysicsShellHolder* ref_obj,EType _type/*=etBox*/,u16	flags)
{
	VERIFY(ref_obj);
	R_ASSERT(_valid( start_pos ) );
	R_ASSERT( _valid( start_size ) );

	m_body			=	dBodyCreate	(0)												;
	dMass m;
	dMassSetSphere(&m,1.f,100000.f);
	dMassAdjust(&m,1.f);
	dBodySetMass(m_body,&m);
	switch(_type)
	{
	case etBox:
	m_geom			=	dCreateBox	(0,start_size.x,start_size.y,start_size.z)		;
	break;

	case etSphere:
	m_geom			=	dCreateSphere	(0,start_size.x);
	break;
	};

	dGeomCreateUserData				(m_geom)										;
	dGeomUserDataSetObjectContactCallback(m_geom,ActivateTestDepthCallback)			;
	dGeomUserDataSetPhysicsRefObject(m_geom,ref_obj)								;
	dGeomSetBody					(m_geom,m_body)									;
	dBodySetPosition				(m_body,start_pos.x,start_pos.y,start_pos.z)	;
	Island()		.AddBody		(m_body)										;
	dBodyEnable						(m_body)										;
	m_safe_state					.create(m_body)									;
	spatial_register				()												;
	m_flags.set(flags,TRUE);
}
Example #3
0
void CInventoryItem::PH_A_CrPr		()
{
	net_updateData* p					= NetSync();
	//restore recalculated data and get data for interpolation	
	if (!object().CrPr_IsActivated())	return;
	////////////////////////////////////
	CPHSynchronize* pSyncObj			= NULL;
	pSyncObj = object().PHGetSyncItem	(0);
	if (!pSyncObj)						return;
	////////////////////////////////////
	pSyncObj->get_State					(p->PredictedState);
	////////////////////////////////////
	pSyncObj->set_State					(p->RecalculatedState);
	////////////////////////////////////

	if (!m_flags.test(FInInterpolate)) return;
	////////////////////////////////////
	Fmatrix xformX;
	pSyncObj->cv2obj_Xfrom(p->PredictedState.quaternion, p->PredictedState.position, xformX);

	VERIFY2								(_valid(xformX),*object().cName());
	pSyncObj->cv2obj_Xfrom				(p->PredictedState.quaternion, p->PredictedState.position, xformX);
	
	p->IEndRot.set						(xformX);
	p->IEndPos.set						(xformX.c);
	VERIFY2								(_valid(p->IEndPos),*object().cName());
	/////////////////////////////////////////////////////////////////////////
	CalculateInterpolationParams		();
	///////////////////////////////////////////////////
};
Example #4
0
void CPostprocessAnimator::SetDesiredFactor	(float f, float sp)			
{
	m_dest_factor=f;
	m_factor_speed=sp;
	VERIFY				(_valid(m_factor));
	VERIFY				(_valid(m_dest_factor));
};
Example #5
0
void CWeapon::UpdateFireDependencies_internal()
{
	if (Device.dwFrame!=dwFP_Frame) 
	{
		dwFP_Frame			= Device.dwFrame;

		UpdateXForm			();

		if ( GetHUDmode() )
		{
			HudItemData()->setup_firedeps		(m_current_firedeps);
			VERIFY(_valid(m_current_firedeps.m_FireParticlesXForm));
		} else 
		{
			// 3rd person or no parent
			Fmatrix& parent			= XFORM();
			Fvector& fp				= vLoadedFirePoint;
			Fvector& fp2			= vLoadedFirePoint2;
			Fvector& sp				= vLoadedShellPoint;

			parent.transform_tiny	(m_current_firedeps.vLastFP,fp);
			parent.transform_tiny	(m_current_firedeps.vLastFP2,fp2);
			parent.transform_tiny	(m_current_firedeps.vLastSP,sp);
			
			m_current_firedeps.vLastFD.set	(0.f,0.f,1.f);
			parent.transform_dir	(m_current_firedeps.vLastFD);

			m_current_firedeps.m_FireParticlesXForm.set(parent);
			VERIFY(_valid(m_current_firedeps.m_FireParticlesXForm));
		}
	}
}
Example #6
0
void CPHSkeleton::UnsplitSingle(CPHSkeleton* SO)
{
	//Msg("%o,received has %d,",this,m_unsplited_shels.size());
	if (0==m_unsplited_shels.size())	return;	//. hack
	CPhysicsShellHolder* obj = PPhysicsShellHolder();
	CPhysicsShellHolder* O =SO->PPhysicsShellHolder();
	VERIFY2(m_unsplited_shels.size(),"NO_SHELLS !!");
	VERIFY2(!O->m_pPhysicsShell,"this has shell already!!!");
	CPhysicsShell* newPhysicsShell=m_unsplited_shels.front().first;
	O->m_pPhysicsShell=newPhysicsShell;
	VERIFY(_valid(newPhysicsShell->mXFORM));
	IKinematics *newKinematics=smart_cast<IKinematics*>(O->Visual());
	IKinematics *pKinematics  =smart_cast<IKinematics*>(obj->Visual());

	Flags64 mask0,mask1;
	u16 split_bone=m_unsplited_shels.front().second;
	mask1.assign(pKinematics->LL_GetBonesVisible());//source bones mask
	pKinematics->LL_SetBoneVisible(split_bone,FALSE,TRUE);

	pKinematics->CalculateBones_Invalidate	();
	pKinematics->CalculateBones				(TRUE);

	mask0.assign(pKinematics->LL_GetBonesVisible());//first part mask
	VERIFY2(mask0.flags,"mask0 -Zero");
	mask0.invert();
	mask1.and(mask0.flags);//second part mask


	newKinematics->LL_SetBoneRoot		(split_bone);
	VERIFY2(mask1.flags,"mask1 -Zero");
	newKinematics->LL_SetBonesVisible	(mask1.flags);

	newKinematics->CalculateBones_Invalidate	();
	newKinematics->CalculateBones				(TRUE);

	newPhysicsShell->set_Kinematics(newKinematics);
	VERIFY(_valid(newPhysicsShell->mXFORM));
	newPhysicsShell->ResetCallbacks(split_bone,mask1);
	VERIFY(_valid(newPhysicsShell->mXFORM));

	newPhysicsShell->ObjectInRoot().identity();

	if(!newPhysicsShell->isEnabled())O->processing_deactivate();
	newPhysicsShell->set_PhysicsRefObject(O);
	
	m_unsplited_shels.erase(m_unsplited_shels.begin());
	O->setVisible(TRUE);
	O->setEnabled(TRUE);


	SO->CopySpawnInit		();
	CopySpawnInit			();
	VERIFY3(CheckObjectSize(pKinematics),*(O->cNameVisual()),"Object unsplit whith no size");
	VERIFY3(CheckObjectSize(newKinematics),*(O->cNameVisual()),"Object unsplit whith no size");

}
Example #7
0
long int strtol(const char *ptr, char **endptr, int base)
{
	int ret = 0;
	int negative = 1;

	if (endptr != NULL)
		*endptr = (char *) ptr;

	/* Purge whitespace */

	for( ; *ptr && isspace(*ptr); ptr++);

	if (ptr[0] == '-') {
		negative = -1;
		ptr++;
	}

	if (!*ptr)
		return 0;

	/* Determine the base */

	if (base == 0) {
		if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
			base = 16;
		else if (ptr[0] == '0') {
			base = 8;
			ptr++;
		}
		else
			base = 10;
	}

	/* Base 16 allows the 0x on front - so skip over it */

	if (base == 16) {
		if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X'))
			ptr += 2;
	}

	/* If the first character isn't valid, then don't
	 * bother */

	if (!*ptr || !_valid(*ptr, base))
		return 0;

	for( ; *ptr && _valid(*ptr, base); ptr++)
		ret = (ret * base) + _offset(*ptr, base);

	if (endptr != NULL)
		*endptr = (char *) ptr;

	return ret * negative;
}
Example #8
0
void CPhysicsShellHolder::correct_spawn_pos()
{
	VERIFY								(PPhysicsShell());
	
	if( H_Parent() )
	{
		CPhysicsShellHolder	* P = smart_cast<CPhysicsShellHolder*>(H_Parent());
		if( P && P->has_shell_collision_place(this) )
			return;
	}

	Fvector								size;
	Fvector								c;
	get_box								(PPhysicsShell(),XFORM(),size,c);

	R_ASSERT2( _valid( c ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) );
	R_ASSERT2( _valid( size ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) );
	R_ASSERT2( _valid( XFORM() ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) );

	CPHActivationShape					activation_shape;
	activation_shape.Create				(c,size,this);
	activation_shape.set_rotation		(XFORM());
	PPhysicsShell()->DisableCollision	();
	activation_shape.Activate			(size,1,1.f,M_PI/8.f);
////	VERIFY								(valid_pos(activation_shape.Position(),phBoundaries));
//	if (!valid_pos(activation_shape.Position(),phBoundaries)) {
//		CPHActivationShape				activation_shape;
//		activation_shape.Create			(c,size,this);
//		activation_shape.set_rotation	(XFORM());
//		activation_shape.Activate		(size,1,1.f,M_PI/8.f);
////		VERIFY							(valid_pos(activation_shape.Position(),phBoundaries));
//	}
	
	PPhysicsShell()->EnableCollision	();

	Fvector								ap = activation_shape.Position();
#ifdef DEBUG
	if (!valid_pos(ap,phBoundaries)) {
		Msg("not valid position	%f,%f,%f",ap.x,ap.y,ap.z);
		Msg("size	%f,%f,%f",size.x,size.y,size.z);
		Msg("Object: %s",Name());
		Msg("Visual: %s",*(cNameVisual()));
		Msg("Object	pos	%f,%f,%f",Position().x,Position().y,Position().z);
	}
#endif // DEBUG
	VERIFY								(valid_pos(activation_shape.Position(),phBoundaries));
	
	Fmatrix								trans;
	trans.identity						();
	trans.c.sub							(ap,c);
	PPhysicsShell()->TransformPosition	(trans);
	PPhysicsShell()->GetGlobalTransformDynamic(&XFORM());
	activation_shape.Destroy			();
}
Example #9
0
float CWound::TotalSize()
{
	float total_size = 0.f;
	for(int i=0; i<ALife::eHitTypeMax; i++)
	{
		VERIFY(_valid(m_Wounds[i]));
		total_size += m_Wounds[i];
	}
	VERIFY(_valid(total_size));
	return total_size;
}
Example #10
0
BOOL CPostprocessAnimator::Process(SPPInfo &PPInfo)
{
	if(m_bCyclic)
		fLifeTime				= 100000;

	CEffectorPP::Process		(PPInfo);
	

	if(m_start_time<0.0f)m_start_time=Device.fTimeGlobal;
	if(m_bCyclic &&((Device.fTimeGlobal-m_start_time)>f_length)) m_start_time+=f_length;

	Update					(Device.fTimeGlobal-m_start_time);

	VERIFY				(_valid(m_factor));
	VERIFY				(_valid(m_factor_speed));
	VERIFY				(_valid(m_dest_factor));
	if(m_bStop)
		m_factor			-=	Device.fTimeDelta*m_factor_speed;
	else
		m_factor			+= m_factor_speed*Device.fTimeDelta*(m_dest_factor-m_factor);

	clamp					(m_factor, 0.0001f, 1.0f);

	VERIFY				(_valid(m_factor));
	VERIFY				(_valid(m_factor_speed));

	m_EffectorParams.color_base		+= pp_identity.color_base;
	m_EffectorParams.color_gray		+= pp_identity.color_gray;
	m_EffectorParams.color_add		+= pp_identity.color_add;

	if(0==m_Params[pp_noise_i]->get_keys_count()){
		m_EffectorParams.noise.intensity = pp_identity.noise.intensity;
	}
	
	if(0==m_Params[pp_noise_g]->get_keys_count()){
		m_EffectorParams.noise.grain = pp_identity.noise.grain;
	}

	if(0==m_Params[pp_noise_f]->get_keys_count()){
		m_EffectorParams.noise.fps = pp_identity.noise.fps;
	}else
		m_EffectorParams.noise.fps		*= 100.0f;

	PPInfo.lerp				(pp_identity, m_EffectorParams, m_factor);

	if(PPInfo.noise.grain<=0.0f){
		R_ASSERT3(0,"noise.grain cant be zero! see postprocess",*m_Name);
	}

	if(fsimilar(m_factor,0.0001f,EPS_S))
		return FALSE;

	return TRUE;
}
Example #11
0
void CWeaponAmmo::UpdateCL() 
{
	VERIFY2								(_valid(renderable.xform),*cName());
	inherited::UpdateCL	();
	VERIFY2								(_valid(renderable.xform),*cName());
	
	if(!IsGameTypeSingle())
		make_Interpolation	();

	VERIFY2								(_valid(renderable.xform),*cName());

}
Example #12
0
void CCustomZone::UpdateBlowoutLight	()
{
	if(m_fLightTimeLeft > (float)Device.dwTimeGlobal)
	{
		float time_k	= m_fLightTimeLeft - (float)Device.dwTimeGlobal;

//		m_fLightTimeLeft -= Device.fTimeDelta;
		clamp(time_k, 0.0f, m_fLightTime*1000.0f);

		float scale		= time_k/(m_fLightTime*1000.0f);
		scale			= powf(scale+EPS_L, 0.15f);
		float r			= m_fLightRange*scale;
		VERIFY(_valid(r));
		m_pLight->set_color(m_LightColor.r*scale, 
							m_LightColor.g*scale, 
							m_LightColor.b*scale);
		m_pLight->set_range(r);

		Fvector pos			= Position();
		pos.y				+= m_fLightHeight;
		m_pLight->set_position(pos);
	}
	else
		StopBlowoutLight ();
}
Example #13
0
void        CPostprocessAnimator::Stop       (float sp)
{
	if(m_bStop)			return;
	m_bStop				= true;
	VERIFY				(_valid(sp));
	m_factor_speed		= sp;
}
Example #14
0
SPPInfo& SPPInfo::lerp(const SPPInfo& def, const SPPInfo& to, float factor)
{
	VERIFY(_valid(factor));
	SPPInfo& pp = *this;
	clamp(factor, 0.0f, 1.0f);

	pp.duality.h		+= def.duality.h		+ (to.duality.h			- def.duality.h)		* factor; 			
	pp.duality.v		+= def.duality.v		+ (to.duality.v			- def.duality.v)		* factor;
	pp.gray				+= def.gray				+ (to.gray				- def.gray)				* factor;
	pp.blur				+= def.blur				+ (to.blur				- def.blur)				* factor;
	pp.noise.intensity	= to.noise.intensity;//	+ (to.noise.intensity	- def.noise.intensity)	* factor;
	pp.noise.grain		= to.noise.grain;//		+ (to.noise.grain		- def.noise.grain)		* factor;
	pp.noise.fps		= to.noise.fps; //		+ (to.noise.fps			- def.noise.fps)		* factor;	

	pp.color_base.set	(
		def.color_base.r	+ (to.color_base.r - def.color_base.r) * factor, 
		def.color_base.g	+ (to.color_base.g - def.color_base.g) * factor, 
		def.color_base.b	+ (to.color_base.b - def.color_base.b) * factor
		);

	pp.color_gray.set	(
		def.color_gray.r	+ (to.color_gray.r - def.color_gray.r) * factor, 
		def.color_gray.g	+ (to.color_gray.g - def.color_gray.g) * factor, 
		def.color_gray.b	+ (to.color_gray.b - def.color_gray.b) * factor
		);

	pp.color_add.set	(
		def.color_add.r	+ (to.color_add.r - def.color_add.r) * factor, 
		def.color_add.g	+ (to.color_add.g - def.color_add.g) * factor, 
		def.color_add.b	+ (to.color_add.b - def.color_add.b) * factor
		);
	return *this;
}
Example #15
0
void CParticlesObject::UpdateSpatial()
{
	if(g_dedicated_server)		return;

	// spatial	(+ workaround occasional bug inside particle-system)
	if (_valid(renderable.visual->vis.sphere))
	{
		Fvector	P;	float	R;
		renderable.xform.transform_tiny	(P,renderable.visual->vis.sphere.P);
		R								= renderable.visual->vis.sphere.R;
		if (0==spatial.type)	{
			// First 'valid' update - register
			spatial.type			= STYPE_RENDERABLE;
			spatial.sphere.set		(P,R);
			spatial_register		();
		} else {
			BOOL	bMove			= FALSE;
			if		(!P.similar(spatial.sphere.P,EPS_L*10.f))		bMove	= TRUE;
			if		(!fsimilar(R,spatial.sphere.R,0.15f))			bMove	= TRUE;
			if		(bMove)			{
				spatial.sphere.set	(P, R);
				spatial_move		();
			}
		}
	}
}
Example #16
0
//------------------------------------------------------------------------------
// calculate
//------------------------------------------------------------------------------
IC void	KEY_Interp	(CKey& D,const CKey& K1,const CKey& K2, float delta)
{
	VERIFY			(_valid(delta));
	VERIFY			(delta>=0.f && delta<=1.f);
	D.Q.slerp		(K1.Q,K2.Q,delta);
	D.T.lerp		(K1.T,K2.T,delta);
}
Example #17
0
gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr)
{
    uint8_t best = 0;
    gnrc_sixlowpan_ctx_t *res = NULL;

    mutex_lock(&_ctx_mutex);

    for (unsigned int id = 0; id < GNRC_SIXLOWPAN_CTX_SIZE; id++) {
        if (_valid(id)) {
            uint8_t match = ipv6_addr_match_prefix(&_ctxs[id].prefix, addr);

            if ((_ctxs[id].prefix_len <= match) && (match > best)) {
                best = match;
                res = &(_ctxs[id]);
            }
        }
    }

    mutex_unlock(&_ctx_mutex);

#if ENABLE_DEBUG
    if (res != NULL) {
        DEBUG("6lo ctx: found context (%u, %s/%" PRIu8 ") ",
              (res->flags_id & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK),
              ipv6_addr_to_str(ipv6str, &res->prefix, sizeof(ipv6str)),
              res->prefix_len);
        DEBUG("for address %s\n", ipv6_addr_to_str(ipv6str, addr, sizeof(ipv6str)));
    }
#endif

    return res;
}
Example #18
0
void CHelicopter::startRocket(u16 idx)
{
	if((getRocketCount()>=1)&&m_use_rocket_on_attack) {
		CExplosiveRocket* pGrenade = smart_cast<CExplosiveRocket*>(getCurrentRocket());
		VERIFY(pGrenade);
		pGrenade->SetInitiator(this->ID());
		
		Fmatrix rocketXFORM;
		(idx==1)?rocketXFORM=m_left_rocket_bone_xform:rocketXFORM=m_right_rocket_bone_xform;

		Fvector vel;
		Fvector dir;
		dir.sub(m_enemy.destEnemyPos, rocketXFORM.c ).normalize_safe();
		vel.mul(dir,CRocketLauncher::m_fLaunchSpeed);

		Fmatrix xform;
		xform.identity();
		xform.k.set(dir);
		Fvector::generate_orthonormal_basis(xform.k,xform.j,xform.i);
		xform.c = rocketXFORM.c;
		VERIFY2(_valid(xform),"CHelicopter::startRocket. Invalid xform");
		LaunchRocket(xform,  vel, zero_vel);

		NET_Packet P;
		u_EventGen(P,GE_LAUNCH_ROCKET,ID());
		P.w_u16(u16( getCurrentRocket()->ID()));
		u_EventSend(P);

		dropCurrentRocket();

		m_last_launched_rocket = idx;
		HUD_SOUND_ITEM::PlaySound(m_sndShotRocket, xform.c, this, false);

	}
}
Example #19
0
BOOL CObject::net_Spawn			(CSE_Abstract* data)
{
	PositionStack.clear			();

	VERIFY						(_valid(renderable.xform));

	if (0==Visual() && pSettings->line_exist( cNameSect(), "visual" ) )
		cNameVisual_set	(pSettings->r_string( cNameSect(), "visual" ) );

	if (0==collidable.model) 	{
		if (pSettings->line_exist(cNameSect(),"cform")) {
			//LPCSTR cf			= pSettings->r_string	(*cNameSect(), "cform");
			VERIFY3				(*NameVisual, "Model isn't assigned for object, but cform requisted",*cName());
			collidable.model	= xr_new<CCF_Skeleton>	(this);
		}
	}
	R_ASSERT(spatial.space);	spatial_register();

	if (register_schedule())
		shedule_register		();

	// reinitialize flags
//.	Props.bActiveCounter		= 0;	
	processing_activate			();
	setDestroy					(false);

	MakeMeCrow					();

	return TRUE					;
}
Example #20
0
void CCustomMonster::shedule_Update	( u32 DT )
{
	VERIFY				(!g_Alive() || processing_enabled());
	// Queue shrink
	VERIFY				(_valid(Position()));
	u32	dwTimeCL		= Level().timeServer()-NET_Latency;
	VERIFY				(!NET.empty());
	while ((NET.size()>2) && (NET[1].dwTimeStamp<dwTimeCL)) NET.pop_front();

	float dt			= float(DT)/1000.f;
	// *** general stuff
	if (g_Alive()) {
		if ( false && g_mt_config.test(mtAiVision) )
#ifndef DEBUG
			Device.seqParallel.push_back	(fastdelegate::FastDelegate0<>(this,&CCustomMonster::Exec_Visibility));
#else // DEBUG
		{
			if (!psAI_Flags.test(aiStalker) || !!smart_cast<CActor*>(Level().CurrentEntity()))
				Device.seqParallel.push_back(fastdelegate::FastDelegate0<>(this,&CCustomMonster::Exec_Visibility));
			else
				Exec_Visibility				();
		}
#endif // DEBUG
		else
			Exec_Visibility					();
		memory().update						(dt);
	}
float	CIKLimbsController::StaticObjectShift			( const SCalculateData cd[max_size] )
{
		const float current_shift = _object_shift.shift();

		u16 cnt = 0; float shift_up =0;
		const u16 sz =(u16)_bone_chains.size();
		for(u16 j = 0; sz > j; ++j )
			if( cd[j].state.foot_step )
			{
				float s_up = cd[j].cl_shift.y + current_shift;
				if( 0.f < s_up )
				{
					shift_up += s_up;
					++cnt;
				}
			} 
		if( 0 < cnt )
				shift_up /= cnt;
		float shift_down = LegLengthShiftLimit( current_shift, cd );
		float shift = 0;
		if( shift_down > 0.f )
			shift = -shift_down;
		else if( -shift_down < shift_up )
			shift = -shift_down;
		else
			shift = shift_up;
		VERIFY( _valid( shift ) );
		_object_shift.set_taget( shift , _abs( current_shift - shift ) / static_shift_object_speed );
		return shift;
}
Example #22
0
void	imotion_position::rootbone_callback	( CBoneInstance *BI )
{
	imotion_position *im = ( imotion_position* )BI->callback_param();
	VERIFY( im );
	if( !im->update_callback.update )
		return;
	VERIFY( im->shell );
	IKinematics *K  = im->shell->PKinematics( );
	VERIFY( K );
	IKinematicsAnimated *KA = smart_cast<IKinematicsAnimated *>( K );
	VERIFY( KA );
	SKeyTable	keys;
	KA->LL_BuldBoneMatrixDequatize( &K->LL_GetData( 0 ), u8(-1), keys );
	
	CKey *key = 0;
	for( int i = 0; i < keys.chanel_blend_conts[0]; ++i )
	{
		if ( keys.blends[0][i] == im->blend)
			key = &keys.keys[0][i];
	}
	if( key )
	{
		key->Q.rotation( Fvector().set( 0, 1, 0 ), im->angle );
	}
	KA->LL_BoneMatrixBuild( *BI, &Fidentity, keys );

	R_ASSERT2( _valid(BI->mTransform), "imotion_position::rootbone_callback" );
}
Example #23
0
void ESceneAIMapTool::CalculateNodesBBox(Fbox& bb)
{
    bb.invalidate();
	for (AINodeIt b_it=m_Nodes.begin(); b_it!=m_Nodes.end(); ++b_it)
    {
    	VERIFY(_valid((*b_it)->Pos));
    	bb.modify((*b_it)->Pos);
    }
}
Example #24
0
bool CActor::g_LadderOrient()
{
	Fvector leader_norm;
	character_physics_support()->movement()->GroundNormal(leader_norm);
	if(_abs(leader_norm.y)>M_SQRT1_2) return false;
	//leader_norm.y=0.f;
	float mag=leader_norm.magnitude();
	if(mag<EPS_L) return false;
	leader_norm.div(mag);
	leader_norm.invert();
	Fmatrix M;M.set(Fidentity);
	M.k.set(leader_norm);
	M.j.set(0.f,1.f,0.f);
	generate_orthonormal_basis1(M.k,M.j,M.i);
	M.i.invert();
	//M.j.invert();


	//Fquaternion q1,q2,q3;
	//q1.set(XFORM());
	//q2.set(M);
	//q3.slerp(q1,q2,dt);
	//Fvector angles1,angles2,angles3;
	//XFORM().getHPB(angles1.x,angles1.y,angles1.z);
	//M.getHPB(angles2.x,angles2.y,angles2.z);
	////angle_lerp(angles3.x,angles1.x,angles2.x,dt);
	////angle_lerp(angles3.y,angles1.y,angles2.y,dt);
	////angle_lerp(angles3.z,angles1.z,angles2.z,dt);

	//angles3.lerp(angles1,angles2,dt);
	////angle_lerp(angles3.y,angles1.y,angles2.y,dt);
	////angle_lerp(angles3.z,angles1.z,angles2.z,dt);
	//angle_lerp(angles3.x,angles1.x,angles2.x,dt);
	//XFORM().setHPB(angles3.x,angles3.y,angles3.z);
	Fvector position;
	position.set(Position());
	//XFORM().rotation(q3);
	VERIFY2(_valid(M),"Invalide matrix in g_LadderOrient");
	XFORM().set(M);
	VERIFY2(_valid(position),"Invalide position in g_LadderOrient");
	Position().set(position);
	VERIFY(_valid(XFORM()));
	return true;
}
Example #25
0
void	phys_shell_verify_object_model( CObject& O )	
{
	IRenderVisual	*V = O.Visual();
	VERIFY2( V, make_string( "Can not create physics shell for object %s it has no model", O.cName().c_str() )+ make_string("\n object dump: \n") + dbg_object_full_dump_string( &O ) );
	IKinematics		*K = V->dcast_PKinematics();
	VERIFY2( K, make_string( "Can not create physics shell for object %s, model %s is not skeleton", O.cName().c_str(), O.cNameVisual().c_str() ) );
	VERIFY2( has_physics_collision_shapes( *K ), make_string( "Can not create physics shell for object %s, model %s has no physics collision shapes set", O.cName().c_str(), O.cNameVisual().c_str() )+ make_string("\n object dump: \n") + dbg_object_full_dump_string( &O )  );
	VERIFY2( _valid( O.XFORM() ), make_string( "create physics shell: object matrix is not valide" ) + make_string("\n object dump: \n") + dbg_object_full_dump_string( &O ) );
	VERIFY2(valid_pos( O.XFORM().c ),  dbg_valide_pos_string( O.XFORM().c, &O, "create physics shell" ) );
}
IC	void CSoundMemoryManager::update_sound_threshold			()
{
	VERIFY		(_valid(m_self_sound_factor));
	VERIFY		(_valid(m_sound_threshold));
	VERIFY		(_valid(m_min_sound_threshold));
	VERIFY		(!fis_zero(m_decrease_factor));
	VERIFY		(m_sound_decrease_quant);
	// t = max(t*f^((tc - tl)/tq),min_threshold)
	m_sound_threshold		= _max(
		m_self_sound_factor*
		m_sound_threshold*
		exp(
			float(Device.dwTimeGlobal - m_last_sound_time)/
			float(m_sound_decrease_quant)*
			log(m_decrease_factor)
		),
		m_min_sound_threshold
	);
	VERIFY		(_valid(m_sound_threshold));
}
void CSoundMemoryManager::reinit				()
{
	m_sounds				= 0;
	m_priorities.clear		();
	m_last_sound_time		= 0;
	m_sound_threshold		= m_min_sound_threshold;
	VERIFY					(_valid(m_sound_threshold));
#ifdef USE_SELECTED_SOUND
	xr_delete				(m_selected_sound);
#endif
}
Example #28
0
void CCharacterPhysicsSupport::ActivateShell			( CObject* who )
{
	R_ASSERT( _valid(m_EntityAlife.Position( )) );
	Fvector start;start.set( m_EntityAlife.Position( ) );
	Fvector velocity;
	Fvector death_position;
	CreateShell( who, death_position, velocity );
	EndActivateFreeShell( who, start ,death_position, velocity );
	VERIFY( m_pPhysicsShell );
	m_pPhysicsShell->Enable();
	m_pPhysicsShell->set_LinearVel( Fvector().set(0,-1,0) );
}
Example #29
0
void ISpatial_DB::insert(ISpatial* S)
{
    cs.Enter();
#ifdef DEBUG
    stat_insert.Begin();

    BOOL bValid = _valid(S->spatial.sphere.R) && _valid(S->spatial.sphere.P);
    if (!bValid)
    {
        CObject* O = dynamic_cast<CObject*>(S);
        if (O) Debug.fatal(DEBUG_INFO, "Invalid OBJECT position or radius (%s)", O->cName());
        else
        {
            CPS_Instance* P = dynamic_cast<CPS_Instance*>(S);
            if (P) Debug.fatal(DEBUG_INFO, "Invalid PS spatial position{%3.2f,%3.2f,%3.2f} or radius{%3.2f}", VPUSH(S->spatial.sphere.P), S->spatial.sphere.R);
            else Debug.fatal(DEBUG_INFO, "Invalid OTHER spatial position{%3.2f,%3.2f,%3.2f} or radius{%3.2f}", VPUSH(S->spatial.sphere.P), S->spatial.sphere.R);
        }
    }
#endif

    if (verify_sp(S, m_center, m_bounds))
    {
        // Object inside our DB
        rt_insert_object = S;
        _insert(m_root, m_center, m_bounds);
        VERIFY(S->spatial_inside());
    }
    else
    {
        // Object outside our DB, put it into root node and hack bounds
        // Object will reinsert itself until fits into "real", "controlled" space
        m_root->_insert(S);
        S->spatial.node_center.set(m_center);
        S->spatial.node_radius = m_bounds;
    }
#ifdef DEBUG
    stat_insert.End();
#endif
    cs.Leave();
}
Example #30
0
void CInventoryItem::PH_I_CrPr		()		// actions & operations between two phisic prediction steps
{
	net_updateData* p					= NetSync();
	//store recalculated data, then we able to restore it after small future prediction
	if (!object().CrPr_IsActivated())	return;
	////////////////////////////////////
	CPHSynchronize* pSyncObj			= NULL;
	pSyncObj = object().PHGetSyncItem	(0);
	if (!pSyncObj)						return;
	////////////////////////////////////
	pSyncObj->get_State					(p->RecalculatedState);
	///////////////////////////////////////////////
	Fmatrix xformX;
	pSyncObj->cv2obj_Xfrom(p->RecalculatedState.quaternion, p->RecalculatedState.position, xformX);

	VERIFY2								(_valid(xformX),*object().cName());
	pSyncObj->cv2obj_Xfrom				(p->RecalculatedState.quaternion, p->RecalculatedState.position, xformX);

	p->IRecRot.set(xformX);
	p->IRecPos.set(xformX.c);
	VERIFY2								(_valid(p->IRecPos),*object().cName());
};