Page 1 of 1

An Explanation of Hitzones

Posted: Thu Jan 22, 2009 6:21 pm
by snick

Re: An Explanation of Hitzones

Posted: Fri Jan 23, 2009 12:02 pm
by Destroyer
Hm nice one snick!

Re: An Explanation of Hitzones

Posted: Fri Jan 23, 2009 2:57 pm
by snick
Destroyer wrote:Hm nice one snick!
Thanks. A couple of things to add. Firstly, I've been asked to share my code for
displaying the hitzone discs[1] in bzflag. After all, squares are instrinsically bad
(they have pointy bits that could take an eye out) and circles are nice[2]. The
code follows and I've attached a patch file. Here's what it looks like in BZFlag:

Image

Original src/bzflag/RadarRenderer.cxx snippet:

Code: Select all

  // draw the tank
  if ((player == NULL) || !useTankDimensions) {
    // align to the screen axes
    glRotatef(float(myAngle * 180.0 / M_PI), 0.0f, 0.0f, 1.0f);
    glRectf(-size, -size, +size, +size);
  }
Replacement code:

Code: Select all

  // draw the tank
  if ((player == NULL) || !useTankDimensions) {
    // align to the screen axes
    // glRotatef(float(myAngle * 180.0 / M_PI), 0.0f, 0.0f, 1.0f);
    // glRectf(-size, -size, +size, +size);

    float hitzone = 4.245f;

    glBegin(GL_TRIANGLES);
    for (float a = 0.0f; a < 6.29f; a += 0.262) {
        glVertex2f(0.0f, 0.0f);
        glVertex2f(hitzone * cosf(a), hitzone * sinf(a));
        glVertex2f(hitzone * cosf(a + 0.262), hitzone * sinf(a + 0.262));
    }
    glEnd();
  }
Patch file:

[The extension diff has been deactivated and can no longer be displayed.]

Warnings: It's terribly unoptimized. Please use responsibly (not in matches etc.).

Secondly, having spoken to a couple of people, it appears that my second diagram
may have caused confusion. Let me say now that the right angle vertex does not touch
the sphere surface, hard though it is to see that in the picture.

[1] It's actually the hitzone slice S that is shown. Please see page 2 referred to above.
[2] Vicious circles excepted.

Re: An Explanation of Hitzones

Posted: Fri Jan 23, 2009 3:19 pm
by dexter
Nice of you to share that with us. I compiled a client with it and my tank did not really show up as a circle on the radar. Somehow a cross between circle and square, I have to play with it some more and see what's up. Anyways, good job. :)

Re: An Explanation of Hitzones

Posted: Fri Jan 23, 2009 3:36 pm
by snick
dexter wrote:Nice of you to share that with us. I compiled a client with it and my tank did not really show up as a circle on the radar. Somehow a cross between circle and square, I have to play with it some more and see what's up. Anyways, good job. :)
You may be seeing the height box. Try jumping and see if the box gets bigger.

Re: An Explanation of Hitzones

Posted: Sat Jan 24, 2009 5:49 pm
by ts
There were already questions whether it is allowed in GU league matches. The answer is no and the reason is that any patch not listed in our whitelist is not allowed.

Re: An Explanation of Hitzones

Posted: Tue Feb 03, 2009 2:00 pm
by snick
Please note: I have found a bug that can cause the effective hitzone
to vary (depends on framerate, affects hittability[1]). Further details:

http://my.bzflag.org/bb/viewtopic.php?f=32&t=13649

Regards,

Snick.

[1] Presumably not in the OED :)