| 222 | } |
| 223 | |
| 224 | void cursorupdate() // called every frame from hud |
| 225 | { |
| 226 | ASSERT(editmode); |
| 227 | if(cleanedit) return; |
| 228 | flrceil = camera1->pitch >= 0 ? 2 : 0; |
| 229 | editaxis = fabs(camera1->pitch) > 60 ? "\161\15\15"[flrceil] : "\160\13\14\157"[(int(camera1->yaw + 45) / 90) & 3]; |
| 230 | |
| 231 | volatile float x = worldpos.x; // volatile needed to prevent msvc7 optimizer bug? |
| 232 | volatile float y = worldpos.y; |
| 233 | volatile float z = worldpos.z; |
| 234 | |
| 235 | cx = (int)x; |
| 236 | cy = (int)y; |
| 237 | |
| 238 | if(OUTBORD(cx, cy)) |
| 239 | { |
| 240 | forceinsideborders(cx); |
| 241 | forceinsideborders(cy); |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | sqr *s = S(cx,cy); |
| 246 | |
| 247 | if(fabs(sheight(s,s,z)-z)>1) // selected wall |
| 248 | { |
| 249 | x += x>camera1->o.x ? 0.5f : -0.5f; // find right wall cube |
| 250 | y += y>camera1->o.y ? 0.5f : -0.5f; |
| 251 | |
| 252 | cx = (int)x; |
| 253 | cy = (int)y; |
| 254 | |
| 255 | if(OUTBORD(cx, cy)) |
| 256 | { |
| 257 | forceinsideborders(cx); |
| 258 | forceinsideborders(cy); |
| 259 | return; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | if(dragging) makesel(false); |
| 264 | |
| 265 | const int GRIDSIZE = 5; |
| 266 | const float GRIDW = 0.5f; |
| 267 | const float GRID8 = 2.0f; |
| 268 | const float GRIDS = 2.0f; |
| 269 | const int GRIDM = 0x7; |
| 270 | |
| 271 | static int lastsparkle = 0; |
| 272 | bool sparkletime = lastmillis - lastsparkle >= 20; |
| 273 | if(sparkletime) lastsparkle = lastmillis - (lastmillis%20); // clip adding sparklies at 50 fps |
| 274 | |
| 275 | // render editing grid |
| 276 | extern int blankouthud; |
| 277 | |
| 278 | if(showgrid && !blankouthud) |
| 279 | { |
| 280 | for(int ix = cx-GRIDSIZE; ix<=cx+GRIDSIZE; ix++) for(int iy = cy-GRIDSIZE; iy<=cy+GRIDSIZE; iy++) |
| 281 | { |
no test coverage detected