PDA

Просмотр полной версии : [Вопрос] кубоид, 2 точки, 6 координат



Batya_Montes
07.02.2018, 14:13
привет, друзья, собственно вопрос вот в чем:
если взять 2 точки (min и max), относительно куба, а потом проверить 3 точку на принадлежность ее к внутренностям, то всегда будет возвращаться, что она не принадлежит


new Float:pos_min[MAX_PLAYERS][6], pos_num[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/pos1", cmdtext, true, 10) == 0)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(pos_num[playerid] == 0)
{
pos_min[playerid][0] = x;
pos_min[playerid][1] = y;
pos_min[playerid][2] = z;
pos_num[playerid] ++;
} else if ( pos_num[playerid] == 1 )
{
pos_min[playerid][3] = x;
pos_min[playerid][4] = y;
pos_min[playerid][5] = z;
pos_num[playerid] ++;
}
else
{
if( x >= pos_min[playerid][0] && x <= pos_min[playerid][3] && y >= pos_min[playerid][1] && y <= pos_min[playerid][4] && z >= pos_min[playerid][2] &&
z <= pos_min[playerid][5] )
{
SendClientMessage(playerid, -1, "вы внутри");
}
else
{
SendClientMessage(playerid, -1, "вы не внутри");
}
pos_num[playerid] = 0;
}
return 1;
}
return 0;
}

DeimoS
07.02.2018, 15:29
Ну так просто залогируй значение каждой переменной и поймёшь в чём проблема.