📄 ivp_environment.hxx
字号:
// Copyright (C) Ipion Software GmbH 1999-2000. All rights reserved.
//IVP_EXPORT_PUBLIC
/********************************************************************************
* File: ivp_environment.hxx
* Description: ???
* Attention: stdio.h must be included before.
********************************************************************************/
#ifndef _IVP_ENVIRONMENT_INCLUDED
#define _IVP_ENVIRONMENT_INCLUDED
#ifndef WIN32
# pragma interface
#endif
#define IVP_Environment_Magic_Number 123456
#define IVP_MOVEMENT_CHECK_COUNT 10 //do not always check movement state
class IVP_BetterStatisticsmanager;
class IVP_Sim_Units_Manager;
class IVP_OV_Tree_Manager;
class IVP_Collision_Filter;
class IVP_Range_Manager;
class IVP_Controller_Manager;
class IVP_U_Active_Value_Manager;
class IVP_Material_Manager;
class IVP_U_Memory;
class IVP_Listener_PSI;
class IVP_Environment_Manager;
class IVP_Application_Environment;
class IVP_Event_Collision;
class IVP_Event_Object;
class IVP_Debug_Manager;
class IVP_Draw_Vector_Debug;
class IVP_Debug_Manager;
class IVP_Actuator_Spring;
class IVP_Template_Spring;
class IVP_Actuator_Suspension;
class IVP_Template_Suspension;
class IVP_Template_Force;
class IVP_Template_Torque;
class IVP_Template_Rot_Mot;
class IVP_Template_Stabilizer;
class IVP_Template_Check_Dist;
class IVP_Controller_Motion;
class IVP_Actuator_Spring;
class IVP_Actuator_Force;
class IVP_Actuator_Torque;
class IVP_Actuator_Rot_Mot;
class IVP_Actuator_Stabilizer;
class IVP_Actuator_Check_Dist;
class IVP_Template_Constraint;
class IVP_Constraint;
class IVP_Collision_Delegator_Root;
class IVP_PerformanceCounter;
class IVP_Anomaly_Manager;
class IVP_Anomaly_Limits;
/********************************************************************************
* Name: IVP_ENV_STATE
* Description: State of the IVP_Environment
********************************************************************************/
enum IVP_ENV_STATE {
IVP_ES_PSI, // Normal PSI controller mode
IVP_ES_PSI_INTEGRATOR,
IVP_ES_PSI_HULL, // Special PSI mode, where no forces are allowed
IVP_ES_PSI_SHORT,
IVP_ES_PSI_CRITIC,
IVP_ES_AT // Between PSIs (Any Time), normally a collision
};
/********************************************************************************
* Name: IVP_Statistic_Manager
* Description: Collects statistic information
********************************************************************************/
class IVP_Statistic_Manager {
public:
IVP_Environment *l_environment;
//statistic section
IVP_Time last_statistic_output;
// impact section
IVP_FLOAT max_rescue_speed;
IVP_FLOAT max_speed_gain;
int impact_sys_num;
int impact_counter; // number of total impacts
int impact_sum_sys; // number of system impacts (which are much faster)
int impact_hard_rescue_counter; // number of bad impacts (very slow movement)
int impact_rescue_after_counter;
int impact_delayed_counter; // number of impacts, where one object gets a delayed speed update
int impact_coll_checks; // number of AT collision checks during impacts
int impact_unmov;
IVP_DOUBLE sum_energy_destr;
// collision checks section
int sum_of_mindists; // number of mindists (not cleared by clear_statistic)
int mindists_generated; // number of mindist just created
int mindists_deleted; // number of just deleted mindists
int range_intra_exceeded; // number of events: sphere for checking two objects recalculated
int range_world_exceeded; // number of events: sphere for checking object - world recalculated
// friction
int processed_fmindists; // number of calls to recalc_friction_s_vals
int global_fmd_counter;
void clear_statistic();
void output_statistic();
IVP_Statistic_Manager();
};
class IVP_Freeze_Manager {
public:
void init_freeze_manager();
IVP_FLOAT freeze_check_dtime; // default 0.3 sec
IVP_Freeze_Manager();
};
class IVP_Listener_Constraint
{
public:
virtual void event_constraint_broken(IVP_Constraint *) = 0;
#ifdef HAVANA_CONSTRAINTS
virtual void event_constraint_broken(class hk_Breakable_Constraint*) = 0;
#endif // HAVANA_CONSTRAINTS
};
/********************************************************************************
* Name: IVP_Environment
* Description: The physical world:
* The is the main class to handle simulation
********************************************************************************/
class IVP_Environment { // the environment
friend class IVP_Simulation_Unit;
friend class IVP_Friction_System;
friend class IVP_Friction_Sys_Static;
friend class IVP_Friction_Solver;
friend class IVP_Friction_Core_Pair;
friend class IVP_Impact_Solver; //for debug statistics only
friend class IVP_Impact_System; //for debug statistics only
friend class IVP_Impact_Solver_Long_Term; //for debug statistics only
friend class IVP_Contact_Point; // for debug statistics only
friend class IVP_Environment_Manager;
friend class IVP_Time_Event_PSI;
friend class IVP_Real_Object;
friend class IVP_Time_Manager;
friend class IVP_Mindist_Manager;
friend class IVP_Calc_Next_PSI_Solver;
friend class IVP_Mindist;
friend class IVP_Core;
class IVP_Standard_Gravity_Controller *standard_gravity_controller;
IVP_Time_Manager *time_manager;
IVP_Sim_Units_Manager *sim_units_manager;
IVP_Cluster_Manager *cluster_manager;
IVP_Mindist_Manager *mindist_manager;
IVP_OV_Tree_Manager *ov_tree_manager;
IVP_Collision_Filter *collision_filter;
IVP_Range_Manager *range_manager;
IVP_Anomaly_Manager *anomaly_manager;
IVP_Anomaly_Limits *anomaly_limits;
IVP_PerformanceCounter *performancecounter;
class IVP_Universe_Manager *universe_manager;
class IVP_Real_Object *static_object; // used for anchors which are not fixed to objects
IVP_Statistic_Manager statistic_manager;
IVP_Freeze_Manager freeze_manager;
IVP_BetterStatisticsmanager *better_statisticsmanager;
IVP_Controller_Manager *controller_manager;
IVP_Cache_Object_Manager *cache_object_manager;
IVP_U_Active_Value_Manager *l_active_value_manager; // backlink to local environment manager
IVP_Material_Manager *l_material_manager;
IVP_U_Memory *short_term_mem; //temporary memory (use only between start_memory_transaction and end_memory_transaction)
IVP_U_Memory *sim_unit_mem; //memory is cleaned when sim_unit or impact_system is finished
IVP_DOUBLE time_since_last_blocking;
IVP_DOUBLE delta_PSI_time; // delta time between two PSIs ( default 1/66 seconds. range: IVP_MAX_DELTA_PSI_TIME - IVP_MIN_DELTA_PSI_TIME seconds )
IVP_DOUBLE inv_delta_PSI_time;
IVP_U_Point gravity; // gravity in meter/(sec*sec) see do_gravity() in core
IVP_FLOAT gravity_scalar; // same as above but only length
IVP_U_Vector<IVP_Listener_Collision> collision_listeners;
IVP_U_Vector<IVP_Listener_PSI> psi_listeners;
IVP_U_Vector<IVP_Core> core_revive_list;
IVP_U_Vector<IVP_Listener_Constraint> constraint_listeners;
char *auth_costumer_name;
unsigned int auth_costumer_code;
int pw_count;
IVP_Environment(IVP_Environment_Manager *manager,IVP_Application_Environment *appl_env,const char *costumer_name,unsigned int auth_code);
IVP_Environment_Manager *environment_manager;
void simulate_psi(IVP_Time psi_time);
inline IVP_BOOL must_perform_movement_check() {
next_movement_check--;
if(next_movement_check==0) {
next_movement_check=IVP_MOVEMENT_CHECK_COUNT*3/2 + (short)(ivp_rand() * (IVP_MOVEMENT_CHECK_COUNT/2));
return IVP_TRUE;
} else {
return IVP_FALSE;
}
};
void add_revive_core(IVP_Core *r_obj);
void remove_revive_core(IVP_Core *r_obj);
void revive_cores_PSI(); // at the beginning of PSI: revive cores
IVP_Time current_time;
IVP_Time time_of_next_psi;
IVP_Time time_of_last_psi; // not for public usage
IVP_Time_CODE current_time_code;
IVP_Time_CODE mindist_event_timestamp_reference;
short next_movement_check;
IVP_ENV_STATE state;
void set_current_time(IVP_Time time);
void do_d_events();
// INTERN_END
#ifdef DEBUG
void invalid_time_code(){ current_time_code++;}; // invalid current time code
#endif
void fire_event_pre_collision( IVP_Event_Collision *);
void fire_event_post_collision( IVP_Event_Collision *);
void fire_event_friction_created( class IVP_Event_Friction *coll);
void fire_event_friction_deleted( class IVP_Event_Friction *coll);
void fire_event_friction_pair_created( class IVP_Friction_Core_Pair *pair);
void fire_event_friction_pair_deleted( class IVP_Friction_Core_Pair *pair);
void fire_event_PSI( );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -