]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Change the way material intensity is calculated, to account the velocity of the objec...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 27 Oct 2011 11:57:13 +0000 (14:57 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Thu, 27 Oct 2011 11:57:13 +0000 (14:57 +0300)
defaultXonotic.cfg
qcsrc/server/mutators/sandbox.qc

index d0de6f89b0a964892d576a29832fef1b4cb05fa3..8fdfc6342a10eba5df68f77fef9903b2d53b5a78 100644 (file)
@@ -547,7 +547,7 @@ set g_sandbox_editor_distance_spawn 200 "distance at which objects spawn in fron
 set g_sandbox_editor_distance_edit 350 "distance at which players can edit or remove objects they are looking at"
 set g_sandbox_object_scale_min 0.1 "minimum scale that objects can be set to"
 set g_sandbox_object_scale_max 2 "maximum scale that objects can be set to"
-set g_sandbox_object_material_velocity_min 200 "velocity objects must have while colliding for material effects to be applied"
+set g_sandbox_object_material_velocity_min 100 "velocity objects must have while colliding for material effects to be applied"
 set g_sandbox_object_material_velocity_factor 0.002 "velocity range which decides the intensity of material effects"
 
 seta menu_sandbox_spawn_model "" // used to store the model in the input field
index 9afe34ffb3c09ccd3a8270c744d30b9f44398e68..3b07fc8b55c594c5818f12adbd07e0d99f21a7b4 100644 (file)
@@ -15,12 +15,15 @@ void sandbox_Object_Touch()
        if(self.touch_timer > time)
                return; // don't execute each frame
        self.touch_timer = time + 0.1;
-       if not(vlen(self.velocity) > autocvar_g_sandbox_object_material_velocity_min || vlen(other.velocity) > autocvar_g_sandbox_object_material_velocity_min)
-               return; // impact not strong enough
 
-       // make particle count and sound intensity depend on impact speed
+       // make particle count and sound volume depend on impact speed
        float intensity;
-       intensity = (vlen(self.velocity) + vlen(other.velocity)) / 2;
+       intensity = vlen(self.velocity) + vlen(other.velocity);
+       if(intensity) // check this first to avoid divisions by 0
+               intensity /= 2; // average the two velocities
+       if not(intensity >= autocvar_g_sandbox_object_material_velocity_min)
+               return; // impact not strong enough to do anything
+       // now offset intensity and apply it to the effects
        intensity = bound(0, intensity * autocvar_g_sandbox_object_material_velocity_factor, 1);
 
        switch(self.material)