OK... I have rewritten my verlet library to eliminate the slow stuff.
The trouble I am having now is when I try to limit the magnitude of my vectors based on the distance they have traveled... for some reason is zeros out the vectors. Here is the code:
I have highlighted the part that is causing the problem. Strangly enough, when I put a stop in the function and trace the variables, everything appears to work fine.
The trouble I am having now is when I try to limit the magnitude of my vectors based on the distance they have traveled... for some reason is zeros out the vectors. Here is the code:
Function verlet_inertia_entity(entity) hash = verlet_get_hash(entity) ;get an array reference based on the entity number elapsed_millisecs# = MilliSecs() - verlet_last_clock(hash) ;elapsed milliseconds since last time manipulating this entity elapsed_seconds# = elapsed_millisecs# / 1000.00 ;converted elapsed milliseconds to elapsed seconds dampening# = 1.0 - (verlet_dampening#(hash) * elapsed_seconds#) ;multiply this by vectors to dampen them according to setting init_x# = EntityX#(entity, True) ;record the position of an entity before movement init_y# = EntityY#(entity, True) init_z# = EntityZ#(entity, True) gravity# = (-9.8 * elapsed_seconds# * verlet_gravity#(hash)) ;this is how much gravity will move the entity verlet_vector_x#(hash) = (verlet_vector_x#(hash) * dampening#) ;dampen the vectors and add gravity verlet_vector_y#(hash) = (verlet_vector_y#(hash) * dampening#) + gravity# verlet_vector_z#(hash) = (verlet_vector_z#(hash) * dampening#) movement_x# = (verlet_vector_x#(hash) * elapsed_seconds#) ;calculate the movement by multiplying vector times elapsed seconds movement_y# = (verlet_vector_y#(hash) * elapsed_seconds#) movement_z# = (verlet_vector_z#(hash) * elapsed_seconds#) TranslateEntity entity, movement_x#, movement_y#, movement_z#, True ; move the entity verlet_constrain_entity(entity) ;constrain an entity to it's linked entities final_x# = EntityX#(entity, True) ;find out the positions now that we moved the entity final_y# = EntityY#(entity, True) final_z# = EntityZ#(entity, True) distance_x# = final_x# - init_x# ;figure out the distance for each vector we moved. distance_y# = final_y# - init_y# distance_z# = final_z# - init_z# seconds_adjustment# = 1.0 / elapsed_seconds# ;calculate how many times our elapsed seconds fits into a second ;THIS PART IS CAUSING TROUBLE!!!****************************************************** verlet_vector_x#(hash) = (distance_x# * seconds_adjustment#) ;limit vectors by setting them to the distance moved scaled over a second verlet_vector_y#(hash) = (distance_y# * seconds_adjustment#) verlet_vector_z#(hash) = (distance_y# * seconds_adjustment#) ;************************************************************************************* verlet_last_clock(hash) = MilliSecs() ;update the milliseconds End Function
I have highlighted the part that is causing the problem. Strangly enough, when I put a stop in the function and trace the variables, everything appears to work fine.