Inside3D!
     

Smooth Rotation Single Player "Cheat"

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Jun 22, 2010 11:36 am    Post subject: Smooth Rotation Single Player "Cheat" Reply with quote

Rotating brush models look great until you walk on them and the default bytes indicating angles makes everything jerky --- almost as bad as hipnotic rotating brushes.

Rather than reinvent a protocol or do something annoying, I've found the easiest fix is the "if no one is looking, do whatever you want" theory of protocols.

In single player, if you aren't recording a demo or playing a demo and you aren't connected to a server or hosting one ... who cares whether your "protocol" is standard as it is operating in absolute isolation.

Code:
#define PRIVATE_PROTOCOL_OK   (sv.active && cls.state != ca_dedicated && !cls.demoplayback && !cls.demorecording && svs.maxclients == 1)

void MSG_WriteAngle (sizebuf_t *sb, float f)
{
#ifdef SMOOTH_SINGLEPLAYER_TEST
   if (PRIVATE_PROTOCOL_OK)
      MSG_WriteFloat (sb, f);
   else
#endif   
   MSG_WriteByte (sb, ((int)f*256/360) & 255);
}

.
.
.

float MSG_ReadAngle (void)
{
#ifdef SMOOTH_SINGLEPLAYER_TEST
   if (PRIVATE_PROTOCOL_OK)
      return MSG_ReadFloat();
   else
#endif
   return MSG_ReadChar() * (360.0/256);
}


Smooth as imaginable.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...


Last edited by Baker on Tue Jun 22, 2010 12:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Tue Jun 22, 2010 12:10 pm    Post subject: Reply with quote

:)

but does still contribute to packet overflows, a significant problem with spammy mods.
also, you forgot to test for recording demos.

Also, as an extra side-note, your existing code rounds towards 0, meaning the angle is 1/512th to the left, which is easily noticable when zoomed and spamming the sng.
Also sent as a byte and read as a char, but whatever.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
mh



Joined: 12 Jan 2008
Posts: 910

PostPosted: Tue Jun 22, 2010 12:17 pm    Post subject: Reply with quote

Baker wrote:
"if no one is looking, do whatever you want"


Very Happy Very Happy Very Happy
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Jun 22, 2010 12:32 pm    Post subject: Reply with quote

Spike wrote:
but does still contribute to packet overflows, a significant problem with spammy mods.


Worthy of road testing testing, hence the #ifdef

Quote:
also, you forgot to test for recording demos.


Thanks, nice catch! Actually I did have that in there and lost it upon messing around with the definition.

Add: "&& !cls.demorecording"

(Edited first post for completeness ...)

Quote:
Also, as an extra side-note, your existing code rounds towards 0, meaning the angle is 1/512th to the left, which is easily noticable when zoomed and spamming the sng.


Original Quake code. Not really actually used in practice by me (ProQuake, JoeQuake, Qrack use the ProQuake "ReadPreciseAngle" short).

Ironically, I can feel the difference in single player enough that fixing the bad rounding gets on my nerves because rockets shoot too "straight" forward.

Quote:
Also sent as a byte and read as a char, but whatever.


I just opened the original source to see if it was like that or if I otherwise somehow inherited that from some other engine.

But actually that is original Q1 Carmack-written code.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
frag.machine



Joined: 25 Nov 2006
Posts: 728

PostPosted: Tue Jun 22, 2010 1:58 pm    Post subject: Reply with quote

IIRC ReadChar() is just a wrapper to ReadByte() without any cast at all, so again, who cares ? Laughing
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/
Back to top
View user's profile Send private message Visit poster's website
mh



Joined: 12 Jan 2008
Posts: 910

PostPosted: Tue Jun 22, 2010 3:41 pm    Post subject: Reply with quote

If you're worried about packet overflow you could quantize to unsigned shorts instead of to bytes. That would be accurate to about 0.005 degrees, which I reckon is enough for anyone.
_________________
DirectQ Engine - New release 1.8.666a, 9th August 2010
MHQuake Blog (General)
Direct3D 8 Quake Engines
Back to top
View user's profile Send private message Visit poster's website
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Tue Jun 22, 2010 4:21 pm    Post subject: Reply with quote

0.005?
you need 0.0005 in order to be enough for anyone.
640k graduations.

okay, bad joke. :s

but yeah, increasing the number of graduations by a mere 25500% is probably enough that noone would notice.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Wed Jun 23, 2010 5:19 pm    Post subject: Reply with quote

frag.machine wrote:
IIRC ReadChar() is just a wrapper to ReadByte() without any cast at all, so again, who cares ? Laughing


ReadChar returns signed char
ReadByte returns unsigned char

if that matters...?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group