forked from elastomania/across
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ED_CHECK.CPP
140 lines (127 loc) · 3.57 KB
/
ED_CHECK.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "all.h"
// Visszaadja, hogy volt-e hiba:
int check_topology( int kelldialog ) {
dialog( "Checking Topology, please wait!",
"GOMBOK", "VISSZATER" );
// Eloszor egymason fekvo szomszedos pontokat valasztjuk szet:
for( int i = 0; i < MAXGYURU; i++ ) {
gyuru* pgy = Ptop->ptomb[i];
if( pgy )
pgy->szetvalaszt();
}
// Most megszuntetjuk hegyes szogeket:
for( i = 0; i < MAXGYURU; i++ ) {
gyuru* pgy = Ptop->ptomb[i];
if( pgy )
pgy->pozitivkorjaras(); // Ez automatikusan megcsinalja:
}
// Most megnezzuk, hogy nincs-e tul sok pont osszesen:
int pontszam = 0;
for( i = 0; i < MAXGYURU; i++ ) {
gyuru* pgy = Ptop->ptomb[i];
if( pgy )
pontszam += pgy->pontszam;
}
if( pontszam > 5000 ) {
if( kelldialog ) {
char tmp[100];
sprintf( tmp, "There are %d vertices now in the level.", pontszam );
dialog( "Error: The number of vertices must be less than 5000!",
tmp,
"Please delete some vertices or polygons from this level!" );
invalidateegesz();
return 1;
}
else {
return 1;
}
}
// Most megnezzuk, hogy nincsenek-e egymast metszo vonalak:
for( i = 0; i < MAXGYURU; i++ ) {
gyuru* pgy = Ptop->ptomb[i];
if( pgy ) {
for( int j = 0; j < pgy->pontszam; j++ ) {
vekt2 r = pgy->ponttomb[j];
vekt2 v;
if( j == pgy->pontszam-1 )
v = pgy->ponttomb[0] - r;
else
v = pgy->ponttomb[j+1] - r;
// Megvan r, v szakasz, amirol el kell donteni, hogy van-e
// metszespontja akarmi massal:
for( int k = 0; k < MAXGYURU; k++ ) {
gyuru* pgy2 = Ptop->ptomb[k];
if( pgy2 ) {
int vanmetszes = 0;
vekt2 m;
if( pgy == pgy2 )
vanmetszes = pgy2->metszeshely( r, v, j, &m );
else
vanmetszes = pgy2->metszeshely( r, v, -1, &m );
if( vanmetszes ) {
if( kelldialog ) {
zoom( m, 0.0000001 );
dialog( "Error: Two lines are crossing each others!",
"After this dialog you will see the crossing point.",
"Use Zoomout to see where it is located!" );
invalidateegesz();
return 1;
}
else {
return 1;
}
}
}
}
}
}
}
// Most megnezzuk, hogy nincs-e kintlevo objektum:
double x1, y1, x2, y2;
Ptop->getminmax( &x1, &y1, &x2, &y2, 0 );
x1 -= 1.0;
y1 -= 1.0;
x2 += 1.0;
y2 += 1.0;
for( i = 0; i < MAXKEREK; i++ ) {
kerek* pker = Ptop->kerektomb[i];
if( pker ) {
if( pker->r.x < x1 || pker->r.x > x2 ||
pker->r.y < y1 || pker->r.y > y2 ) {
if( kelldialog ) {
zoom( pker->r, 1.5 );
dialog( "Error: An object is outside the level borders!",
"After this dialog you will see the object.",
"Use Zoomout to see where it is located!" );
invalidateegesz();
return 1;
}
else {
return 1;
}
}
}
}
// Most megnezzuk, hogy bal kerek nincs-e kint:
for( i = 0; i < MAXKEREK; i++ ) {
kerek* pker = Ptop->kerektomb[i];
if( pker && pker->tipus == T_KEZDO ) {
if( !Ptop->levegoben( NULL, &pker->r ) ) {
if( kelldialog ) {
dialog( "Error: The start object, which determines the place of the left wheel when you start to",
"play on a particular level, is inside ground!",
"If you cannot resolve this error message, you should try to move this object inside",
"ground, because it is possible that you have mixed up which is the ground and",
"which is the air.",
"After this dialog you will see the object.",
"Use Zoomout to see where it is located!" );
zoom( pker->r, 1.5 );
}
return 1;
}
}
}
if( kelldialog )
dialog( "Everything seems to be all right." );
return 0;
}