MCPcopy Create free account
hub / github.com/assaultcube/AC / mousemove

Function mousemove

source/src/physics.cpp:913–943  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

911FVARP(mfilter, 0.0f, 0.0f, 6.0f); // simple lowpass filtering (zero deactivates the feature)
912
913void mousemove(int idx, int idy)
914{
915 if(intermission || ispaused || (player1->isspectating() && (player1->spectatemode==SM_FOLLOW1ST||player1->spectatemode==SM_OVERVIEW))) return;
916 bool zooming = player1->weaponsel->type == GUN_SNIPER && ((sniperrifle *)player1->weaponsel)->scoped; // check if player uses scope
917 float dx = idx, dy = idy;
918 if(mfilter > 0.0001f)
919 { // simple IIR-like filter (1st order lowpass)
920 static float fdx = 0, fdy = 0;
921 float k = mfilter * 0.1f;
922 dx = fdx = dx * ( 1.0f - k ) + fdx * k;
923 dy = fdy = dy * ( 1.0f - k ) + fdy * k;
924 }
925 double cursens = sensitivity; // basic unscoped sensitivity
926 if(mouseaccel > 0.0001f && curtime && (idx || idy)) cursens += 0.02f * mouseaccel * sqrtf(dx*dx + dy*dy)/curtime; // optionally accelerated
927 if(zooming)
928 { // when scoped:
929 if(scopesens > 0.0001f) cursens = scopesens; // if specified, use dedicated (fixed) scope sensitivity
930 else cursens *= autoscopesens ? autoscopesensscale : scopesensscale; // or adjust sensitivity by given (fixed) factor or based on scopefov/fov
931 }
932 cursens /= 33.0f * sensitivityscale; // final scaling
933
934 camera1->yaw += (float) (dx * cursens);
935 camera1->pitch -= (float) (dy * cursens * (invmouse ? -1 : 1));
936
937 fixcamerarange();
938 if(camera1!=player1 && player1->spectatemode!=SM_DEATHCAM)
939 {
940 player1->yaw = camera1->yaw;
941 player1->pitch = camera1->pitch;
942 }
943}
944
945void entinmap(physent *d) // brute force but effective way to find a free spawn spot in the map
946{

Callers 1

checkinputFunction · 0.85

Calls 2

fixcamerarangeFunction · 0.85
isspectatingMethod · 0.80

Tested by

no test coverage detected