view Renderer/Engine/viewer_types.cc @ 507:735f76483bb2

Reorganization..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:39:35 +0900
parents
children 49b3c753e209
line wrap: on
line source

#include "viewer_types.h"

static int
getLocalPosition(int d, int offset)
{
    /**
     * offset が 2 の冪乗の時だけ使える。
     * 現在は offset は 2 の冪乗のみなので
     * これで問題ないけどどうなの?
     */
    return d & (offset-1);

    // offset が 2 の冪乗以外はこれにしないとだめ
    //return d % offset;
}

/**
 * ワールド座標における x の値を
 * split_screen_w で分割した領域(1 〜 split_screen_w)での座標に変換する
 * (ex. split_screen_w が 256 の場合、
 *      x =   1 -> 1
 *      x = 256 -> 256
 *      x = 257 -> 1
 */
int
getLocalX(int x)
{
    return getLocalPosition(x, split_screen_w);
}

/**
 * getLocalX に同じ
 */
int
getLocalY(int y)
{
    return getLocalPosition(y, split_screen_h);
}