OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Shape.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Basic classes for rectangles and vertex outlines */
19 
20 #include "C4Include.h"
21 #include "object/C4Shape.h"
22 
23 #include "game/C4Physics.h"
24 #include "landscape/C4Material.h"
25 #include "landscape/C4Landscape.h"
26 #include "control/C4Record.h"
27 
28 bool C4Shape::AddVertex(int32_t iX, int32_t iY)
29 {
30  if (VtxNum>=C4D_MaxVertex) return false;
31  VtxX[VtxNum]=iX; VtxY[VtxNum]=iY;
32  VtxNum++;
33  return true;
34 }
35 
37 {
38  InplaceReconstruct(this);
39 }
40 
41 void C4Shape::Rotate(C4Real Angle, bool bUpdateVertices)
42 {
43  C4RCRotVtx rc;
44  int32_t i = 0;
46  {
47  rc.x=x; rc.y=y; rc.wdt=Wdt; rc.hgt=Hgt; rc.r=fixtoi(Angle);
48  for (; i<4; ++i)
49  { rc.VtxX[i]=VtxX[i]; rc.VtxY[i]=VtxY[i]; }
50  AddDbgRec(RCT_RotVtx1, &rc, sizeof(rc));
51  }
52  int32_t cnt,nvtx,nvty,nwdt,nhgt;
53 
54  C4Real mtx[4];
55 
56  // Calculate rotation matrix
57  mtx[0] = Cos(Angle); mtx[1] = -Sin(Angle);
58  mtx[2] = -mtx[1]; mtx[3] = mtx[0];
59 
60  if (bUpdateVertices)
61  {
62  // Rotate vertices
63  for (cnt = 0; cnt < VtxNum; cnt++)
64  {
65  nvtx = fixtoi(mtx[0] * VtxX[cnt] + mtx[1] * VtxY[cnt]);
66  nvty = fixtoi(mtx[2] * VtxX[cnt] + mtx[3] * VtxY[cnt]);
67  VtxX[cnt] = nvtx; VtxY[cnt] = nvty;
68  }
69  }
70 
71  // Enlarge Rect
72  nvtx = fixtoi(mtx[0] * x + mtx[1] * y);
73  nvty = fixtoi(mtx[2] * x + mtx[3] * y);
74  if (mtx[0] > 0)
75  {
76  if (mtx[1] > 0)
77  {
78  nwdt = fixtoi(mtx[0] * Wdt + mtx[1] * Hgt);
79  nhgt = fixtoi(mtx[1] * Wdt + mtx[0] * Hgt);
80  x = nvtx;
81  y = nvty - fixtoi(mtx[1] * Wdt);
82  }
83  else
84  {
85  nwdt = fixtoi(mtx[0] * Wdt - mtx[1] * Hgt);
86  nhgt = fixtoi(- mtx[1] * Wdt + mtx[0] * Hgt);
87  x = nvtx + fixtoi(mtx[1] * Hgt);
88  y = nvty;
89  }
90  }
91  else
92  {
93  if (mtx[1] > 0)
94  {
95  nwdt = fixtoi(- mtx[0] * Wdt + mtx[1] * Hgt);
96  nhgt = fixtoi(mtx[1] * Wdt - mtx[0] * Hgt);
97  x = nvtx + fixtoi(mtx[0] * Wdt);
98  y = nvty - nhgt;
99  }
100  else
101  {
102  nwdt = fixtoi(- mtx[0] * Wdt - mtx[1] * Hgt);
103  nhgt = fixtoi(- mtx[1] * Wdt - mtx[0] * Hgt);
104  x = nvtx - nwdt;
105  y = nvty + fixtoi(mtx[0] * Hgt);
106  }
107  }
108  Wdt = nwdt;
109  Hgt = nhgt;
110  if (Config.General.DebugRec)
111  {
112  rc.x=x; rc.y=y; rc.wdt=Wdt; rc.hgt=Hgt;
113  for (i=0; i<4; ++i)
114  { rc.VtxX[i]=VtxX[i]; rc.VtxY[i]=VtxY[i]; }
115  AddDbgRec(RCT_RotVtx2, &rc, sizeof(rc));
116  }
117 }
118 
119 void C4Shape::Stretch(int32_t iCon, bool bUpdateVertices)
120 {
121  int32_t cnt;
122  x=x*iCon/FullCon;
123  y=y*iCon/FullCon;
124  Wdt=Wdt*iCon/FullCon;
125  Hgt=Hgt*iCon/FullCon;
126  FireTop=FireTop*iCon/FullCon;
127  if (bUpdateVertices)
128  for (cnt=0; cnt<VtxNum; cnt++)
129  {
130  VtxX[cnt]=VtxX[cnt]*iCon/FullCon;
131  VtxY[cnt]=VtxY[cnt]*iCon/FullCon;
132  }
133 }
134 
135 void C4Shape::Jolt(int32_t iCon, bool bUpdateVertices)
136 {
137  int32_t cnt;
138  y=y*iCon/FullCon;
139  Hgt=Hgt*iCon/FullCon;
140  FireTop=FireTop*iCon/FullCon;
141  if (bUpdateVertices)
142  for (cnt=0; cnt<VtxNum; cnt++)
143  VtxY[cnt]=VtxY[cnt]*iCon/FullCon;
144 }
145 
147 {
148  int32_t cnt;
149  rRect.x=rRect.y=rRect.Wdt=rRect.Hgt=0;
150  for (cnt=0; cnt<VtxNum; cnt++)
151  {
152  // Extend left
153  if (VtxX[cnt]<rRect.x)
154  {
155  rRect.Wdt+=rRect.x-VtxX[cnt];
156  rRect.x=VtxX[cnt];
157  }
158  // Extend right
159  else if (VtxX[cnt]>rRect.x+rRect.Wdt)
160  { rRect.Wdt=VtxX[cnt]-rRect.x; }
161 
162  // Extend up
163  if (VtxY[cnt]<rRect.y)
164  {
165  rRect.Hgt+=rRect.y-VtxY[cnt];
166  rRect.y=VtxY[cnt];
167  }
168  // Extend down
169  else if (VtxY[cnt]>rRect.y+rRect.Hgt)
170  { rRect.Hgt=VtxY[cnt]-rRect.y; }
171  }
172 
173  rRect.Hgt+=rRect.y-y;
174  rRect.y=y;
175 
176 }
177 
178 inline bool C4Shape::CheckTouchableMaterial(int32_t x, int32_t y, int32_t vtx_i, int32_t ydir, const C4DensityProvider &rDensityProvider) {
179  return rDensityProvider.GetDensity(x,y) >= ContactDensity &&
180  ((ydir > 0 && !(CNAT_PhaseHalfVehicle & VtxCNAT[vtx_i])) || !IsMCHalfVehicle(::Landscape.GetPix(x,y)));
181 }
182 
183 // Adjust given position to one pixel before contact
184 // at vertices matching CNAT request.
185 bool C4Shape::Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos)
186 {
187  // reset attached material
189  int xcd = 0;
190  int ycd = 0;
191  // determine attachment direction
192  switch (cnat_pos & (~CNAT_Flags))
193  {
194  case CNAT_Top: ycd=-1; break;
195  case CNAT_Bottom: ycd=+1; break;
196  case CNAT_Left: xcd=-1; break;
197  case CNAT_Right: xcd=+1; break;
198  default: return false;
199  }
200  int testx = cx;
201  int testy = cy;
202  bool increase_distance = true;
203  bool any_contact = false;
204  // Find the nearest position that has at least one vertex adjacent to dense material
205  // and no vertices in dense materials
206  while (Abs(testx - cx) < AttachRange && Abs(testy - cy) < AttachRange)
207  {
208  bool found = false;
209  for (int i = 0; i < VtxNum; ++i)
210  {
211  if (VtxCNAT[i] & cnat_pos)
212  {
213  // get new vertex pos
214  int32_t ax = testx + VtxX[i], ay = testy + VtxY[i];
215  if (CheckTouchableMaterial(ax, ay, i))
216  {
217  found = false;
218  break;
219  }
220  // can attach here?
221  if (CheckTouchableMaterial(ax + xcd, ay + ycd, i, ycd))
222  {
223  found = true;
224  any_contact = true;
225  // store attachment material
226  AttachMat = GBackMat(ax + xcd, ay + ycd);
227  // store absolute attachment position
228  iAttachX = ax + xcd; iAttachY = ay + ycd;
229  iAttachVtx = i;
230  }
231 
232  }
233  }
234  if (found)
235  {
236  cx = testx;
237  cy = testy;
238  return true;
239  }
240  // Try positions in order of distance from the origin,
241  // and alternating the direction
242  testx = cx - (testx - cx);
243  testy = cy - (testy - cy);
244  if (increase_distance)
245  {
246  testx += xcd;
247  testy += ycd;
248  }
249  increase_distance = !increase_distance;
250  }
251  return any_contact;
252 }
253 
254 
255 bool C4Shape::LineConnect(int32_t tx, int32_t ty, int32_t cvtx, int32_t ld, int32_t oldx, int32_t oldy)
256 {
257 
258  if (VtxNum<2) return false;
259 
260  // No modification
261  if ((VtxX[cvtx]==tx) && (VtxY[cvtx]==ty)) return true;
262 
263  // Check new path
264  int32_t ix,iy;
265  if (PathFree(tx,ty,VtxX[cvtx+ld],VtxY[cvtx+ld],&ix,&iy))
266  {
267  // Okay, set vertex
268  VtxX[cvtx]=tx; VtxY[cvtx]=ty;
269  return true;
270  }
271  else
272  {
273  // Intersected, find bend vertex
274  bool found = false;
275  int32_t cix;
276  int32_t ciy;
277  for (int irange = 4; irange <= 12; irange += 4)
278  for (cix = ix - irange / 2; cix <= ix + irange; cix += irange)
279  for (ciy = iy - irange / 2; ciy <= iy + irange; ciy += irange)
280  {
281  if (PathFree(cix,ciy,tx,ty) && PathFree(cix,ciy,VtxX[cvtx+ld],VtxY[cvtx+ld]))
282  {
283  found = true;
284  goto out;
285  }
286  }
287 out:
288  if (!found)
289  {
290  // try bending directly at path the line took
291  // allow going through vehicle in this case to allow lines through castles and elevator shafts
292  cix = oldx;
293  ciy = oldy;
294  if (!PathFreeIgnoreVehicle(cix,ciy,tx,ty) || !PathFreeIgnoreVehicle(cix,ciy,VtxX[cvtx+ld],VtxY[cvtx+ld]))
295  if (!PathFreeIgnoreVehicle(cix,ciy,tx,ty) || !PathFreeIgnoreVehicle(cix,ciy,VtxX[cvtx+ld],VtxY[cvtx+ld]))
296  return false; // Found no bend vertex
297  }
298  // Insert bend vertex
299  if (ld>0)
300  {
301  if (!InsertVertex(cvtx+1,cix,ciy)) return false;
302  }
303  else
304  {
305  if (!InsertVertex(cvtx,cix,ciy)) return false;
306  cvtx++;
307  }
308  // Okay, set vertex
309  VtxX[cvtx]=tx; VtxY[cvtx]=ty;
310  return true;
311  }
312 
313  return false;
314 }
315 
316 bool C4Shape::InsertVertex(int32_t iPos, int32_t tx, int32_t ty)
317 {
318  if (VtxNum+1>C4D_MaxVertex) return false;
319  if (iPos < 0 || iPos > VtxNum) return false;
320  // Insert vertex before iPos
321  for (int32_t cnt=VtxNum; cnt>iPos; cnt--)
322  { VtxX[cnt]=VtxX[cnt-1]; VtxY[cnt]=VtxY[cnt-1]; }
323  VtxX[iPos]=tx; VtxY[iPos]=ty;
324  VtxNum++;
325  return true;
326 }
327 
328 bool C4Shape::RemoveVertex(int32_t iPos)
329 {
330  if (!Inside<int32_t>(iPos,0,VtxNum-1)) return false;
331  for (int32_t cnt=iPos; cnt+1<VtxNum; cnt++)
332  { VtxX[cnt]=VtxX[cnt+1]; VtxY[cnt]=VtxY[cnt+1]; }
333  VtxNum--;
334  return true;
335 }
336 
337 bool C4Shape::CheckContact(int32_t cx, int32_t cy)
338 {
339  // Check all vertices at given object position.
340  // Return true on any contact.
341 
342 
343  for (int32_t cvtx=0; cvtx<VtxNum; cvtx++)
344  if (!(VtxCNAT[cvtx] & CNAT_NoCollision))
345  if (CheckTouchableMaterial(cx+VtxX[cvtx],cy+VtxY[cvtx], cvtx))
346  return true;
347 
348 
349  return false;
350 }
351 
352 bool C4Shape::ContactCheck(int32_t cx, int32_t cy, uint32_t *border_hack_contacts, bool collide_halfvehic)
353 {
354  // Check all vertices at given object position.
355  // Set ContactCNAT and ContactCount.
356  // Set VtxContactCNAT and VtxContactMat.
357  // Return true on any contact.
358 
359 
361  ContactCount=0;
362 
363  for (int32_t cvtx=0; cvtx<VtxNum; cvtx++)
364 
365  // Ignore vertex if collision has been flagged out
366  if (!(VtxCNAT[cvtx] & CNAT_NoCollision))
367 
368  {
370  int32_t x = cx+VtxX[cvtx];
371  int32_t y = cy+VtxY[cvtx];
372  VtxContactMat[cvtx]=GBackMat(x,y);
373 
374  if (CheckTouchableMaterial(x, y, cvtx, collide_halfvehic? 1:0))
375  {
376  ContactCNAT |= VtxCNAT[cvtx];
378  ContactCount++;
379  // Vertex center contact, now check top,bottom,left,right
380  if (CheckTouchableMaterial(x,y-1,cvtx, collide_halfvehic ? 1 : 0))
381  VtxContactCNAT[cvtx]|=CNAT_Top;
382  if (CheckTouchableMaterial(x,y+1,cvtx, collide_halfvehic ? 1 : 0))
384  if (CheckTouchableMaterial(x-1,y,cvtx, collide_halfvehic ? 1 : 0))
385  VtxContactCNAT[cvtx]|=CNAT_Left;
386  if (CheckTouchableMaterial(x+1,y,cvtx, collide_halfvehic ? 1 : 0))
387  VtxContactCNAT[cvtx]|=CNAT_Right;
388  }
389  if (border_hack_contacts)
390  {
391  if (x == 0 && CheckTouchableMaterial(x-1, y, cvtx)) *border_hack_contacts |= CNAT_Left;
392  else if (x == ::Landscape.GetWidth() && CheckTouchableMaterial(x+1, y, cvtx)) *border_hack_contacts |= CNAT_Right;
393  }
394  }
395 
396 
397  return !!ContactCount;
398 }
399 
400 bool C4Shape::CheckScaleToWalk(int x, int y)
401 {
402  for (int32_t i = 0; i < VtxNum; i++)
403  {
404  if (VtxCNAT[i] & CNAT_NoCollision)
405  continue;
406  if (VtxCNAT[i] & CNAT_Bottom)
407  {
408  // no ground under the feet?
409  if (CheckTouchableMaterial(x + VtxX[i], y + VtxY[i] + 1, i))
410  return false;
411  }
412  else
413  {
414  // can climb with hands?
415  if (CheckTouchableMaterial(x + VtxX[i] - 1, y + VtxY[i], i))
416  return false;
417  if (CheckTouchableMaterial(x + VtxX[i] + 1, y + VtxY[i], i))
418  return false;
419  }
420  }
421  return true;
422 }
423 
424 int32_t C4Shape::GetVertexX(int32_t iVertex)
425 {
426  if (!Inside<int32_t>(iVertex,0,VtxNum-1)) return 0;
427  return VtxX[iVertex];
428 }
429 
430 int32_t C4Shape::GetVertexY(int32_t iVertex)
431 {
432  if (!Inside<int32_t>(iVertex,0,VtxNum-1)) return 0;
433  return VtxY[iVertex];
434 }
435 
436 void C4Shape::CopyFrom(C4Shape rFrom, bool bCpyVertices, bool fCopyVerticesFromSelf)
437 {
438  if (bCpyVertices)
439  {
440  // truncate / copy vertex count
441  VtxNum = (fCopyVerticesFromSelf ? std::min<int32_t>(VtxNum, C4D_VertexCpyPos) : rFrom.VtxNum);
442  // restore vertices from back of own buffer (retaining count)
443  int32_t iCopyPos = (fCopyVerticesFromSelf ? C4D_VertexCpyPos : 0);
444  C4Shape &rVtxFrom = (fCopyVerticesFromSelf ? *this : rFrom);
445  memcpy(VtxX, rVtxFrom.VtxX+iCopyPos, VtxNum*sizeof(*VtxX));
446  memcpy(VtxY, rVtxFrom.VtxY+iCopyPos, VtxNum*sizeof(*VtxY));
447  memcpy(VtxCNAT, rVtxFrom.VtxCNAT+iCopyPos, VtxNum*sizeof(*VtxCNAT));
448  memcpy(VtxFriction, rVtxFrom.VtxFriction+iCopyPos, VtxNum*sizeof(*VtxFriction));
449  memcpy(VtxContactCNAT, rVtxFrom.VtxContactCNAT+iCopyPos, VtxNum*sizeof(*VtxContactCNAT));
450  memcpy(VtxContactMat, rVtxFrom.VtxContactMat+iCopyPos, VtxNum*sizeof(*VtxContactMat));
451  // continue: copies other members
452  }
453  *((C4Rect *) this) = rFrom;
454  AttachMat=rFrom.AttachMat;
455  ContactCNAT=rFrom.ContactCNAT;
457  FireTop=rFrom.FireTop;
458 }
459 
461 {
462  // return bottom-most vertex
463  int32_t iMax = -1;
464  for (int32_t i = 0; i < VtxNum; i++)
465  if (VtxCNAT[i] & CNAT_Bottom)
466  if (iMax == -1 || VtxY[i] < VtxY[iMax])
467  iMax = i;
468  return iMax;
469 }
470 
472 {
473  int b = INT_MIN;
474  for (int32_t i = 0; i < VtxNum; i++)
475  if (~VtxCNAT[i] & CNAT_NoCollision)
476  if (VtxY[i] > b)
477  b = VtxY[i];
478  if (b == INT_MIN)
479  return y + Hgt;
480  return b;
481 }
482 
484 
485 int32_t C4DensityProvider::GetDensity(int32_t x, int32_t y) const
486 {
487  // default density provider checks the landscape
488  return GBackDensity(x,y);
489 }
490 
491 int32_t C4Shape::GetVertexContact(int32_t iVtx, DWORD dwCheckMask, int32_t tx, int32_t ty, const C4DensityProvider &rDensityProvider)
492 {
493  // default check mask
494  if (!dwCheckMask) dwCheckMask = VtxCNAT[iVtx];
495  // check vertex positions (vtx num not range-checked!)
496  tx += VtxX[iVtx]; ty += VtxY[iVtx];
497  int32_t iContact = 0;
498  // check all directions for solid mat
499  if (~VtxCNAT[iVtx] & CNAT_NoCollision)
500  {
501  if (dwCheckMask & CNAT_Center) if (CheckTouchableMaterial(tx, ty , iVtx, 0, rDensityProvider)) iContact |= CNAT_Center;
502  if (dwCheckMask & CNAT_Left) if (CheckTouchableMaterial(tx-1, ty, iVtx, 0, rDensityProvider)) iContact |= CNAT_Left;
503  if (dwCheckMask & CNAT_Right) if (CheckTouchableMaterial(tx+1, ty, iVtx, 0, rDensityProvider)) iContact |= CNAT_Right;
504  if (dwCheckMask & CNAT_Top) if (CheckTouchableMaterial(tx, ty-1, iVtx, 0, rDensityProvider)) iContact |= CNAT_Top;
505  if (dwCheckMask & CNAT_Bottom) if (CheckTouchableMaterial(tx, ty+1, iVtx, 1, rDensityProvider)) iContact |= CNAT_Bottom;
506  }
507  // return resulting bitmask
508  return iContact;
509 }
510 
512 {
513  // copy vertices from original buffer, including count
514  VtxNum = std::min<int32_t>(rFrom.VtxNum, C4D_VertexCpyPos);
515  memcpy(VtxX+C4D_VertexCpyPos, rFrom.VtxX, VtxNum*sizeof(*VtxX));
516  memcpy(VtxY+C4D_VertexCpyPos, rFrom.VtxY, VtxNum*sizeof(*VtxY));
517  memcpy(VtxCNAT+C4D_VertexCpyPos, rFrom.VtxCNAT, VtxNum*sizeof(*VtxCNAT));
518  memcpy(VtxFriction+C4D_VertexCpyPos, rFrom.VtxFriction, VtxNum*sizeof(*VtxFriction));
521 }
522 
523 void C4Shape::CompileFunc(StdCompiler *pComp, const C4Shape *default_shape)
524 {
525  const StdBitfieldEntry<int32_t> ContactDirections[] =
526  {
527 
528  { "CNAT_None", CNAT_None },
529  { "CNAT_Left", CNAT_Left },
530  { "CNAT_Right", CNAT_Right },
531  { "CNAT_Top", CNAT_Top },
532  { "CNAT_Bottom", CNAT_Bottom },
533  { "CNAT_Center", CNAT_Center },
534  { "CNAT_MultiAttach", CNAT_MultiAttach },
535  { "CNAT_NoCollision", CNAT_NoCollision },
536  { "CNAT_PhaseHalfVehicle", CNAT_PhaseHalfVehicle },
537 
538  { nullptr, 0 }
539  };
540 
541  // a default shape is given in object compilation context only
542  bool fRuntime = !!default_shape;
543  C4Shape default_def_shape;
544  if (!default_shape) default_shape = &default_def_shape;
545  // Note: Compiled directly into "Object" and "DefCore"-categories, so beware of name clashes
546  // (see C4Object::CompileFunc and C4Def::CompileFunc)
547  pComp->Value(mkNamingAdapt( Wdt, "Width", default_shape->Wdt));
548  pComp->Value(mkNamingAdapt( Hgt, "Height", default_shape->Hgt));
549  pComp->Value(mkNamingAdapt( mkArrayAdaptDefArr(&x,2,&default_shape->x), "Offset", &default_shape->x));
550  pComp->Value(mkNamingAdapt( VtxNum, "Vertices", default_shape->VtxNum));
551  pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxX, default_shape->VtxX), "VertexX", default_shape->VtxX));
552  pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxY, default_shape->VtxY), "VertexY", default_shape->VtxY));
553  pComp->Value(mkNamingAdapt( mkArrayAdaptDMAM(VtxCNAT, default_shape->VtxCNAT, [&](decltype(*VtxCNAT) &elem){ return mkBitfieldAdapt<int32_t>(elem, ContactDirections); }), "VertexCNAT", default_shape->VtxCNAT));
554  pComp->Value(mkNamingAdapt( mkArrayAdaptDMA(VtxFriction, default_shape->VtxFriction), "VertexFriction", default_shape->VtxFriction));
555  pComp->Value(mkNamingAdapt( ContactDensity, "ContactDensity", default_shape->ContactDensity));
556  pComp->Value(mkNamingAdapt( FireTop, "FireTop", default_shape->FireTop));
557  if (fRuntime)
558  {
559  pComp->Value(mkNamingAdapt( iAttachX, "AttachX", 0 ));
560  pComp->Value(mkNamingAdapt( iAttachY, "AttachY", 0 ));
561  pComp->Value(mkNamingAdapt( iAttachVtx, "AttachVtx", 0 ));
562  }
563 }
int VtxX[4]
Definition: C4Record.h:165
Definition: StdAdaptors.h:851
C4Config Config
Definition: C4Config.cpp:837
C4DensityProvider DefaultDensityProvider
Definition: C4Shape.cpp:483
int32_t AttachMat
Definition: C4Shape.h:51
#define mkArrayAdaptDMAM(A, D, M)
Definition: StdAdaptors.h:419
#define b
C4ConfigGeneral General
Definition: C4Config.h:252
const BYTE CNAT_PhaseHalfVehicle
Definition: C4Constants.h:118
int GetBottom()
Definition: C4Shape.cpp:471
int32_t ContactDensity
Definition: C4Shape.h:48
int32_t FireTop
Definition: C4Shape.h:42
Definition: C4Rect.h:29
uint8_t BYTE
const BYTE CNAT_NoCollision
Definition: C4Constants.h:117
bool AddVertex(int32_t iX, int32_t iY)
Definition: C4Shape.cpp:28
int32_t GetBottomVertex()
Definition: C4Shape.cpp:460
void Default()
Definition: C4Shape.cpp:36
int32_t iAttachY
Definition: C4Shape.h:54
const BYTE CNAT_Flags
Definition: C4Constants.h:120
int32_t VtxContactMat[C4D_MaxVertex]
Definition: C4Shape.h:53
int32_t GetVertexX(int32_t iVertex)
Definition: C4Shape.cpp:424
Definition: C4Real.h:58
const int32_t FullCon
Definition: C4Constants.h:182
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
int32_t ContactCount
Definition: C4Shape.h:50
int32_t VtxFriction[C4D_MaxVertex]
Definition: C4Shape.h:47
int32_t Wdt
Definition: C4Rect.h:32
const int32_t MNone
Definition: C4Constants.h:178
void CreateOwnOriginalCopy(C4Shape &rFrom)
Definition: C4Shape.cpp:511
const BYTE CNAT_MultiAttach
Definition: C4Constants.h:116
bool IsMCHalfVehicle(BYTE mat)
Definition: C4Material.h:225
#define C4D_VertexCpyPos
Definition: C4Rect.h:23
int32_t y
Definition: C4Rect.h:32
C4Landscape Landscape
int32_t VtxContactCNAT[C4D_MaxVertex]
Definition: C4Shape.h:52
int32_t GetVertexContact(int32_t iVtx, DWORD dwCheckMask, int32_t tx, int32_t ty, const C4DensityProvider &rDensityProvider=DefaultDensityProvider)
Definition: C4Shape.cpp:491
bool PathFreeIgnoreVehicle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t *ix, int32_t *iy)
int32_t iAttachX
Definition: C4Shape.h:54
int32_t ContactCNAT
Definition: C4Shape.h:49
void CopyFrom(C4Shape rFrom, bool bCpyVertices, bool fCopyVerticesFromSelf)
Definition: C4Shape.cpp:436
int32_t VtxNum
Definition: C4Shape.h:43
int32_t VtxX[C4D_MaxVertex]
Definition: C4Shape.h:44
void AddDbgRec(C4RecordChunkType eType, const void *pData, int iSize)
Definition: C4Record.cpp:36
void Rotate(C4Real Angle, bool bUpdateVertices)
Definition: C4Shape.cpp:41
BYTE GetPix(int32_t x, int32_t y) const
bool RemoveVertex(int32_t iPos)
Definition: C4Shape.cpp:328
int Angle(int iX1, int iY1, int iX2, int iY2)
Definition: Standard.cpp:35
int32_t iAttachVtx
Definition: C4Shape.h:54
void Value(const T &rStruct)
Definition: StdCompiler.h:171
std::enable_if< std::is_nothrow_default_constructible< T >::value >::type InplaceReconstruct(T *obj)
Definition: Standard.h:35
bool PathFree(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
const int C4D_MaxVertex
Definition: C4Constants.h:55
int32_t x
Definition: C4Rect.h:32
const BYTE CNAT_None
Definition: C4Constants.h:109
const BYTE CNAT_Top
Definition: C4Constants.h:112
int32_t GBackDensity(int32_t x, int32_t y)
Definition: C4Landscape.h:227
bool InsertVertex(int32_t iPos, int32_t tx, int32_t ty)
Definition: C4Shape.cpp:316
void GetVertexOutline(C4Rect &rRect)
Definition: C4Shape.cpp:146
const BYTE CNAT_Right
Definition: C4Constants.h:111
void Stretch(int32_t iCon, bool bUpdateVertices)
Definition: C4Shape.cpp:119
bool CheckContact(int32_t cx, int32_t cy)
Definition: C4Shape.cpp:337
bool CheckScaleToWalk(int x, int y)
Definition: C4Shape.cpp:400
bool LineConnect(int32_t tx, int32_t ty, int32_t cvtx, int32_t ld, int32_t oldx, int32_t oldy)
Definition: C4Shape.cpp:255
virtual int32_t GetDensity(int32_t x, int32_t y) const
Definition: C4Shape.cpp:485
int32_t DebugRec
Definition: C4Config.h:61
int32_t GetVertexY(int32_t iVertex)
Definition: C4Shape.cpp:430
void CompileFunc(StdCompiler *pComp, const C4Shape *default_shape)
Definition: C4Shape.cpp:523
int32_t Hgt
Definition: C4Rect.h:32
T Abs(T val)
Definition: Standard.h:44
C4Real Sin(const C4Real &fAngle)
Definition: C4Real.h:265
uint32_t DWORD
const int AttachRange
Definition: C4Physics.h:26
int fixtoi(const C4Fixed &x)
Definition: C4Real.h:259
const BYTE CNAT_Left
Definition: C4Constants.h:110
const BYTE CNAT_Bottom
Definition: C4Constants.h:113
bool Attach(int32_t &cx, int32_t &cy, BYTE cnat_pos)
Definition: C4Shape.cpp:185
C4Real Cos(const C4Real &fAngle)
Definition: C4Real.h:266
int32_t GBackMat(int32_t x, int32_t y)
Definition: C4Landscape.h:222
#define mkArrayAdaptDMA(A, D)
Definition: StdAdaptors.h:416
int32_t GetWidth() const
int32_t VtxCNAT[C4D_MaxVertex]
Definition: C4Shape.h:46
int32_t VtxY[C4D_MaxVertex]
Definition: C4Shape.h:45
void Jolt(int32_t iCon, bool bUpdateVertices)
Definition: C4Shape.cpp:135
int VtxY[4]
Definition: C4Record.h:165
bool ContactCheck(int32_t cx, int32_t cy, uint32_t *border_hack_contacts=0, bool collide_halfvehic=false)
Definition: C4Shape.cpp:352
const BYTE CNAT_Center
Definition: C4Constants.h:114
StdArrayDefaultArrayAdapt< T, D > mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault)
Definition: StdAdaptors.h:415