CString CDiagramEntity::GetString(BOOL bBegin) const
/* ============================================================
	Function :		CDiagramEntity::GetString
	Description :	Creates a string representing the object.
					
	Return :		CString	-	The resulting string
	Parameters :	none

	Usage :			Used to save this object to a text file.

   ============================================================*/
{
	CString str;

	if (bBegin) {
		CRect rect = GetRect();
		str.Format("<control class='%s' name='%s' left='%d' top='%d' width='%d' height='%d' freezed='%d' visible='%d'>", 
			GetType(), GetName(), rect.left, rect.top, rect.Width(), rect.Height(), IsFreezed(), IsVisible());

	} else {
		str = "</control>";
	}

	return str;
}
Beispiel #2
0
void CPHWorld::FrameStep(dReal step)
{
	if(IsFreezed())		return;
	
	VERIFY		(_valid(step))	;
	step	*=	phTimefactor	;
	// compute contact joints and forces

	//step+=astep;

	//const  dReal k_p=24000000.f;//550000.f;///1000000.f;
	//const dReal k_d=400000.f;
	u32 it_number;
	float frame_time=m_frame_time;
	frame_time+=step;
	//m_frame_sum+=step;
#ifdef DEBUG
	if(ph_dbg_draw_mask.test(phDbgDrawObjectStatistics))
	{
		static float dbg_iterations=0.f;
		dbg_iterations=dbg_iterations*0.9f+step/fixed_step*0.1f;
		b_processing=true;
		DBG_OutText("phys steps per frame %2.1f",dbg_iterations);
		b_processing=false;
	}
#endif
	if(!(frame_time<fixed_step))
	{
		it_number				=	iFloor	(frame_time/fixed_step);
		frame_time				-=	it_number*fixed_step;
		m_previous_frame_time	=	m_frame_time;
		m_frame_time			=	frame_time;
		b_frame_mark			=	!b_frame_mark;
	}
	else
	{
		m_frame_time=	frame_time;
		return		;
	}
	//for(UINT i=0;i<(m_reduce_delay+1);++i)
	b_processing=true;

	start_time = Device.dwTimeGlobal;// - u32(m_frame_time*1000);
	if(g_bDebugDumpPhysicsStep&&it_number>20)Msg("!!!TOO MANY PHYSICS STEPS PER FRAME = %d !!!",it_number);
	for(UINT i=0; i<it_number;++i)	Step();
	b_processing=false;
}
CString CGumpEntity::GetString(BOOL bBegin) const
{
	CString str, ret;

	if (bBegin) {
		CRect rect = GetRect();
		str.Format("<control class='%s' name='%s' left='%d' top='%d' width='%d' height='%d' freezed='%d' visible='%d' alpha='%d' flags='%d'>\n", 
			GetType(), GetName(), rect.left, rect.top, rect.Width(), rect.Height(), IsFreezed(), IsVisible(), GetAlpha(), GetFlags());
		ret += str;
		str.Format(" <event onclick='%s' onclose='%s' onmouseup='%s' onmousedown='%s' onkeypressed='%s'/>",
			GetEventHandler(ONCLICK), GetEventHandler(ONCLOSE), GetEventHandler(ONMOUSEUP), GetEventHandler(ONMOUSEDOWN), GetEventHandler(ONKEYPRESSED));
		ret += str;
	} else {
		ret = "</control>";
	}

	return ret;
}
BOOL CDiagramEntity::DoMessage( UINT msg, CDiagramEntity* /*sender*/, CWnd* from )
/* ============================================================
	Function :		CDiagramEntity::DoMessage
	Description :	Message handler for the object.

	Return :		BOOL					-	TRUE to stop 
												further processing.
	Parameters :	UINT msg				-	The message.
					CDiagramEntity* sender	-	Original sender of 
												this message, or 
												NULL if not an object.

	Usage :			The container can send messages to all 
					objects. The messages should lie in the 
					range CMD_START to CMD_STOP inclusively - 
					a few are already predefined in 
					DiagramEntity.h. This function will be 
					called as response to those messages. This 
					mechanism is already used for sending back 
					messages from CDiagramEditor to the 
					relevant object when a object popup menu 
					alternative is selected.

   ============================================================*/
{

	BOOL stop = FALSE;
	switch( msg )
	{
		case CMD_CUT:
			if( m_parent && IsSelected() )
			{
				stop = TRUE;
				m_parent->Cut( this );
			}
		break;

		case CMD_COPY:
			if( m_parent && IsSelected() )
			{
				stop = TRUE;
				m_parent->Copy( this );
			}
		break;

		case CMD_UP:
			if( m_parent && IsSelected() )
			{
				stop = TRUE;
				m_parent->Up( this );
			}
		break;

		case CMD_DOWN:
			if( m_parent && IsSelected() )
			{
				stop = TRUE;
				m_parent->Down( this );
			}
		break;

		case CMD_FRONT:
			if( m_parent && IsSelected() )
			{
				stop = TRUE;
				m_parent->Front( this );
			}
		break;

		case CMD_BOTTOM:
			if( m_parent && IsSelected() )
			{
				stop = TRUE;
				m_parent->Bottom( this );
			}
		break;

		case CMD_DUPLICATE:
			if( m_parent && IsSelected() )
			{
				stop = TRUE;
				m_parent->Duplicate( this );
				Select( FALSE );
			}
		break;

		case CMD_PROPERTIES:
			if( IsSelected() )
			{
				ShowProperties( from ); // MOD
				stop = TRUE;
			}
		break;

		case CMD_FREEZE:
			if( IsSelected() )
			{
				stop = FALSE;
				Freeze(TRUE);
			}
		break;

		case CMD_UNFREEZE_ALL:
			if( IsFreezed() )
			{
				stop = FALSE;
				Freeze(FALSE);
			}
		break;

		case CMD_HIDE:
			if( IsSelected() )
			{
				stop = FALSE;
				SetVisible(FALSE);
			}
		break;

		case CMD_HIDE_UNSEL:
			if( !IsSelected() )
			{
				stop = FALSE;
				SetVisible(FALSE);
			}
		break;

		case CMD_UNHIDE_ALL:
			if( !IsVisible() )
			{
				stop = FALSE;
				SetVisible(TRUE);
			}
		break;
	}

	return stop;

}
BOOL CDiagramEntity::IsSelectable() const
{
	return !IsFreezed() && IsVisible();
}
Beispiel #6
0
void CPHWorld::Step()
{
#ifdef DEBUG
	dbg_reused_queries_per_step	=0			;
	dbg_new_queries_per_step	=0			;
#endif
	
	VERIFY(b_processing||IsFreezed());

	PH_OBJECT_I			i_object;
	PH_UPDATE_OBJECT_I	i_update_object;

	if(disable_count==0)
	{
		disable_count=worldDisablingParams.objects_params.L2frames;
		for(i_object=m_recently_disabled_objects.begin();m_recently_disabled_objects.end() != i_object;)
		{
			CPHObject* obj=(*i_object);
			obj->check_recently_deactivated();
			++i_object;
		}
	}
	--disable_count;

	++m_steps_num;
	Device.Statistic->ph_collision.Begin	();

	for(i_object=m_objects.begin();m_objects.end() != i_object;)
	{
		CPHObject* obj=(*i_object);
		obj->Collide();

		++i_object;
	}
	Device.Statistic->ph_collision.End	();

#ifdef DEBUG
	for(i_object=m_objects.begin();m_objects.end() != i_object;)
	{
		CPHObject* obj=(*i_object);
		DBG_DrawPHObject(obj);
		++i_object;
	}
#endif

	for(i_object=m_objects.begin();m_objects.end() != i_object;)
	{	
		CPHObject* obj=(*i_object);
		++i_object;
		obj->PhTune(fixed_step);
	}

	for(i_update_object=m_update_objects.begin();m_update_objects.end() != i_update_object;)
	{	CPHUpdateObject* obj=(*i_update_object);
		++i_update_object;
		obj->PhTune(fixed_step);
	}

	Device.Statistic->ph_core.Begin		();
#ifdef DEBUG
	dbg_bodies_num=0;
	dbg_joints_num=0;
	dbg_islands_num=0;
#endif
//////////////////////////////////////////////////////////////////////
	m_commander						->update();
//////////////////////////////////////////////////////////////////////
	for(i_object=m_objects.begin();m_objects.end() != i_object;)
	{	
		CPHObject* obj=(*i_object);
		++i_object;
#ifdef DEBUG
		if(ph_dbg_draw_mask.test(phDbgDrawObjectStatistics))
		{
			if(obj->Island().IsActive())
			{
				dbg_islands_num++;
				dbg_joints_num+=obj->Island().nj;
				dbg_bodies_num+=obj->Island().nb;
			}
		}
#endif

		obj->IslandStep(fixed_step);
	}

	Device.Statistic->ph_core.End		();


	for(i_object=m_objects.begin();m_objects.end() != i_object;)
	{
		CPHObject* obj=(*i_object);
		++i_object;
		obj->IslandReinit();
		obj->PhDataUpdate(fixed_step);
		obj->spatial_move();
	}

	for(i_update_object=m_update_objects.begin();m_update_objects.end() != i_update_object;)
	{	CPHUpdateObject* obj=*i_update_object;
	++i_update_object;
	obj->PhDataUpdate(fixed_step);
	}
#ifdef DEBUG
	dbg_contacts_num=ContactGroup->num;
#endif
	dJointGroupEmpty(ContactGroup);//this is to be called after PhDataUpdate!!!-the order is critical!!!
	ContactFeedBacks.empty();
	ContactEffectors.empty();



	if(physics_step_time_callback) 
	{
		physics_step_time_callback(start_time,start_time+u32(fixed_step*1000));	
		start_time += u32(fixed_step*1000);
	};


}