View previous topic :: View next topic |
Author |
Message |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jun 22, 2010 11:36 am Post subject: Smooth Rotation Single Player "Cheat" |
|
|
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 |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Tue Jun 22, 2010 12:10 pm Post subject: |
|
|
:)
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 |
|
 |
mh

Joined: 12 Jan 2008 Posts: 910
|
|
Back to top |
|
 |
Baker

Joined: 14 Mar 2006 Posts: 1538
|
Posted: Tue Jun 22, 2010 12:32 pm Post subject: |
|
|
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 |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Tue Jun 22, 2010 1:58 pm Post subject: |
|
|
IIRC ReadChar() is just a wrapper to ReadByte() without any cast at all, so again, who cares ?  _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
mh

Joined: 12 Jan 2008 Posts: 910
|
Posted: Tue Jun 22, 2010 3:41 pm Post subject: |
|
|
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 |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Tue Jun 22, 2010 4:21 pm Post subject: |
|
|
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 |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Wed Jun 23, 2010 5:19 pm Post subject: |
|
|
frag.machine wrote: | IIRC ReadChar() is just a wrapper to ReadByte() without any cast at all, so again, who cares ?  |
ReadChar returns signed char
ReadByte returns unsigned char
if that matters...? |
|
Back to top |
|
 |
|