⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ivp_core.hxx

📁 hl2 source code. Do not use it illegal.
💻 HXX
📖 第 1 页 / 共 2 页
字号:


    /********************************************************************************
     *	type:		private, public handle with care
     *	section:	initializing basic, non redundant, long time unchangeable section
     ********************************************************************************/    
    void set_radius(IVP_FLOAT upper_limit, IVP_FLOAT max_dev);
    void transform_PSI_matrizes_core(const IVP_U_Matrix *m_core_f_core);	// Multiply matrizes with m_core_f_core
    
    /********************************************************************************
    *	Name:	      	set_mass 	
    *	Description:	sets the mass and multiplies all rot_inertias with
    *                   new_mass/old_mass.
    *   Attention:      Does not update spring constants that are declared
    *   	        relative.
    *                   set_mass is not forwarded to original cores, thus
    *                   set_mass may only temporarly change the mass of the
    *                   object (till next PSI, object breaks .)
    ********************************************************************************/
    void set_mass(IVP_FLOAT mass);
    void set_rotation_inertia( const IVP_U_Float_Point *);

    inline    void clip_velocity(IVP_U_Float_Point *velocity, IVP_U_Float_Point *angular_velocity); // parameters are input and output !!!

    inline void calc_next_PSI_matrix(IVP_U_Vector<IVP_Core> *cores_which_needs_calc_next_psi, class IVP_Event_Sim *){ // call commit_all_calc_next_PSI_matrix afterwards
	cores_which_needs_calc_next_psi->add(this);
    }
    
    void calc_next_PSI_matrix_zero_speed(class IVP_Event_Sim *);
    
    
    /********************************************************************************
     *	type:		public
     *	section:	updates the redundant, long time unchangeable section
     ********************************************************************************/
    void calc_calc();					// calculate redundant part

    void synchronize_with_rot_z();    // synchronize m_world_f_core_last_psi and time_of_last_psi with interpolation
    void undo_synchronize_rot_z();
    
    
    /********************************************************************************
     *	type:		private, internal
     *	section:	core state change handling
     ********************************************************************************/
    void init_core_for_simulation();
    void stop_physical_movement(); // to avoid unwanted inter/extrapolations on calm objects
    void fire_event_object_frozen(); // just send events
    void freeze_simulation_core();
    void stop_movement_without_collision_recheck();
    IVP_BOOL revive_simulation_core(); // returns true when datastructures are changed
    void ensure_core_in_simulation_delayed() { environment->add_revive_core(this); }
    void revive_adjacent_to_unmoveable();
    void ensure_core_to_be_in_simulation();
    void ensure_all_core_objs_in_simulation(); // for merged cores!
    void ensure_all_core_objs_in_simulation_now(); // for merged cores!
    void reset_freeze_check_values();
    
    /********************************************************************************
     *	type:		private, internal
     *	section:	different simulation functions
     ********************************************************************************/
    IVP_Movement_Type calc_movement_state(IVP_Time psi_time);

    void create_collision_merged_core_with(IVP_Core *other_core);		// create a merged core
    void set_matrizes_and_speed(IVP_Core_Merged *template_core, IVP_U_Matrix *m_CORE_f_core_out); // for splitting

    void reset_time( IVP_Time offset);
    void damp_object(IVP_DOUBLE virt_delta_time,const IVP_U_Float_Point *rotation_factor, IVP_DOUBLE speed_factor);
    void global_damp_core(IVP_DOUBLE delta_time);
    
    /********************************************************************************
     *	type:		PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC
     *	type:		PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC
     *	type:		PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC
     *	type:		PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC
     *	type:		PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC PUBLIC
     *	Description:	All functions below this line are meant real public.
     *
     *	Notes:		Use these methods ONLY at PSI!!
     *			floats are used for os and cs and directions
     *			duoble is used for ws
     *
     *	 async_		The core has two sets of speed variables:
     *			speed (rot_speed) and speed_change (rot_speed_change)
     *			the xxx_change variables are used to collect changes to
     *	 		be added to the real values later.
     *			ALL FUNCTIONS, WHICH MODIFY THE xxx_change VARIABLES
     *			HAVE THE async PREFIX
     *	
     *	 test_		In some cases the user does not want to modify the core but
     *			wants to get the result in his own speed and rot_speed variables
     *			THIS FUNCTIONS HAVE THE test_ PREFIX
     *
     *	 _ws		xxx_ws means function/variable works in world space
     *	 _cs		xxx_cs means function/variable works in core space
     *			No such suffix means functions needs parameters defined in different spaces,
     *			check the variable names for details.
     *
     *	 inline_	All inline functions have got the 'inline_' prefix, include ivp_core_macros.hxx
     *			to use them.
     *
     *	 _AT		Means: Any time, not restricted to PSI states
     *			(If not otherwise mentioned, functions work correctly at PSI time only)
     *
     *	 rot_push_  	The 'rot_' prefix means that the function exerts a rotation
     *			impulse only.
     *
     *	 center_push_	the 'center_' prefix means, core is pushed in mass center,
     *			rot_speed is not changed.
     *
     *	_on_test	In all standard situations, the core's speed and rot_speed
     *			variables are taken as source. If these values are parameters
     *			to the function, the _on_test suffix is appended to the
     *			function name
     ********************************************************************************/


    
    /********************************************************************************
     *	section:	get the ws speed of any point fixed in core space
     ********************************************************************************/
    void   get_surface_speed( const IVP_U_Float_Point *position_cs_in, IVP_U_Float_Point *speed_ws_out) const;
    void   get_surface_speed_ws( const IVP_U_Point *position_ws_in, IVP_U_Float_Point *speed_ws_out);
    void   get_surface_speed_on_test(const IVP_U_Float_Point *position_cs_in, const IVP_U_Float_Point *center_speed_in, const IVP_U_Float_Point *rot_speed_in,
				     IVP_U_Float_Point *speed_ws_out) const;
        
   /********************************************************************************
    *	Name:		get_diff_surface_speed_of_two_cores
    *	Description:	core_A->get_surface_speed() - core_B->get_surface_speed()
    ********************************************************************************/
    static void	get_diff_surface_speed_of_two_cores(const IVP_Core *core_A, const IVP_Core *core_B,
						    const IVP_U_Float_Point *position_A_cs, const IVP_U_Float_Point *position_B_cs,
						    IVP_U_Float_Point *speed_ws_A_minus_B_out);
    

    // #+# remove, use inline_get_surface_speed_parallel_to_vector_on_test instead
    static void get_diff_surface_speed_of_two_cores_on_test(const IVP_Core *core_A, const  IVP_Core *core_B,
							    const IVP_U_Float_Point *position_A_cs, const IVP_U_Float_Point *position_B_cs,
							    const IVP_U_Float_Point *speed_A, const IVP_U_Float_Point *rot_speed_A,
							    const IVP_U_Float_Point *speed_B, const IVP_U_Float_Point *rot_speed_B,
							    IVP_U_Float_Point *speed_ws_A_minus_B_out);

    
        
    /********************************************************************************
     *	section:	push the core at a given point and given impulse (#+# will be removed soon)
     ********************************************************************************/
    void       push_core (const IVP_U_Float_Point *position_cs_in, const IVP_U_Float_Point *impulse_cs_in, const IVP_U_Float_Point *impulse_ws_in);
               // very fast, but needs redundant input values
    void async_push_core (const IVP_U_Float_Point *position_cs_in, const IVP_U_Float_Point *impulse_cs_in, const IVP_U_Float_Point *impulse_ws_in);
    
    void  test_push_core (const IVP_U_Float_Point *position_cs_in, const IVP_U_Float_Point *impulse_cs_in, const IVP_U_Float_Point *impulse_ws_in,
			 IVP_U_Float_Point *speed_change_out, IVP_U_Float_Point *rot_change_out) const;
               // very fast, but needs redundant input values
    
   /********************************************************************************
    *	Description:	convinient routines of the above functions
    ********************************************************************************/
    void        push_core_ws( const IVP_U_Point *position_ws, const IVP_U_Float_Point	*impulse_ws);
    void  async_push_core_ws( const IVP_U_Point	*position_ws, const IVP_U_Float_Point	*impulse_ws);

   /********************************************************************************
    *	Description:	apply an impulse at the center of mass
    ********************************************************************************/
    void       center_push_core_multiple_ws(const IVP_U_Float_Point *impulse_ws, IVP_DOUBLE factor = 1.0f);
    void async_center_push_core_multiple_ws(const IVP_U_Float_Point *impulse_ws, IVP_DOUBLE factor = 1.0f);


   /********************************************************************************
    *	Description:	apply an angular impulse at the center of mass
    ********************************************************************************/
    void       rot_push_core_multiple_ws(const IVP_U_Float_Point *angular_impulse_ws, IVP_DOUBLE factor = 1.0f);
    void async_rot_push_core_multiple_ws(const IVP_U_Float_Point *angular_impulse_ws, IVP_DOUBLE factor = 1.0f);

   /*******************************************************************************
    *	Name:	Rot Pushes
    *	Description: Exerts a rotation impulse
    *	Note:	The length of the axis * [factor] is the power of rotation impulse
    ********************************************************************************/
    void       rot_push_core_cs          ( const IVP_U_Float_Point *angular_impulse_cs);
    void       rot_push_core_multiple_cs ( const IVP_U_Float_Point *angular_impulse_cs, IVP_DOUBLE factor = 1.0f);
    void async_rot_push_core_multiple_cs ( const IVP_U_Float_Point *angular_impulse_cs, IVP_DOUBLE factor = 1.0f);
    void  test_rot_push_core_multiple_cs ( const IVP_U_Float_Point *angular_impulse_cs, IVP_DOUBLE factor, IVP_U_Float_Point *delta_rot_speed_out);
    
   /********************************************************************************
    *	Name:	      	get_energy_on_test 	
    *	Description:    Returns the kinetic energy of the object
    ********************************************************************************/
    IVP_DOUBLE get_energy_on_test(const IVP_U_Float_Point *speed_vec, const IVP_U_Float_Point *rot_speed_vec);

    
   /********************************************************************************
    *	Name:	      	get_rot_inertia_cs 	
    *	Description:	Get the virtual projected rotation inertia for one cs axis
    ********************************************************************************/
    IVP_DOUBLE get_rot_inertia_cs(const IVP_U_Float_Point *normized_axis_cs);

   /********************************************************************************
    *	Name:	      	get_rot_speed_cs 	
    *	Description:	Get projected rotation speed for one given axis
    ********************************************************************************/
    IVP_DOUBLE get_rot_speed_cs(  const IVP_U_Float_Point *normized_axis_cs);


    /********************************************************************************
    *	Name:	      	xxx_all_async_pushes	
    *	Description:	handle xxx_change variables of core
    *	Note:		not really for public use, handle with care
    ********************************************************************************/
    void abort_all_async_pushes();			// clear all xxx_change variables
    void commit_all_async_pushes();			// make all asynchronous pushes permanent
    

    IVP_Environment *get_environment() { return this->environment; };
    
   /********************************************************************************
    *	Name:	     	calc_correct_virt_mass  	
    *	Description:	Get the virtual mass of a core space point,
    *			given a core direction and a world direction (e.g. of an assumed force vector).
    *                   Works like calc_virt_mass but slower and more accurately.
    ********************************************************************************/
    IVP_DOUBLE calc_correct_virt_mass(const IVP_U_Float_Point *position_cs,const IVP_U_Float_Point *direction_core,const IVP_U_Float_Point *direction_world) const;

    
   /********************************************************************************
    *	Name:	     	calc_virt_mass  	
    *	Description:	Estimates the virtual mass of a core space point,
    *			given a core direction (e.g. of an assumed force vector).
    ********************************************************************************/
    IVP_DOUBLE calc_virt_mass(const IVP_U_Float_Point *core_point, const  IVP_U_Float_Point *direction)const;	// calc the virtual mass of a point 

    
   /********************************************************************************
    *	Name:	      	calc_virt_mass_worst_case 	
    *	Description:	Same as above, coarse calculation of minimal virt. mass,
    *                   regarding all directions.
    ********************************************************************************/
    IVP_DOUBLE calc_virt_mass_worst_case(const IVP_U_Float_Point *core_point)const;
    

    /*******************************************************************************************
     *	section:	Calculate core matrix/quaternion/position at a user defined time between
     *			last and next PSI
     *******************************************************************************************/
           void calc_at_matrix(IVP_Time current_time, IVP_U_Matrix *m_world_f_core_out) const;  		// calc a matrix at any time
    inline void inline_calc_at_quaternion(IVP_Time time, IVP_U_Quat *quat_out) const; 	
    inline void inline_calc_at_position(IVP_Time time, IVP_U_Point *position_out) const; 	

    
   /********************************************************************************
    *	Name:	       	get_m_world_f_core_PSI
    *	Description:	Get the core matrix at PSI time
    ********************************************************************************/
    const IVP_U_Matrix *get_m_world_f_core_PSI()  { return &m_world_f_core_last_psi; };
    const IVP_U_Point *get_position_PSI() { return m_world_f_core_last_psi.get_position(); };

   /********************************************************************************
    *	Name:	       	values_changed_recalc_redundants
    *	Description:	The mass, rotation inertia, or material of associated object
    *                   changed. Recalculate some internal variables. Pretty fast.
    *                   Call at any time.
    ********************************************************************************/
    void values_changed_recalc_redundants();
};


#endif /* _IVP_CORE_INCLUDED */


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -