OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4SolidMask.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 
17 /* Solid areas of objects, put into the landscape */
18 
19 #ifndef INC_C4SolidMask
20 #define INC_C4SolidMask
21 
22 #include "object/C4ObjectList.h"
23 #include "object/C4Shape.h"
24 
26 {
27 protected:
28  bool MaskPut; // if set, the mask is currently put into landscape
29  int MaskPutRotation; // rotation in which the mask was put (and resides in the buffers)
30  int MatBuffPitch; // pitch (and width) of mat buffer
31 
32  // last position mask was removed from
33  // A rounded position is used for y, even though that causes movement to be less smooth, because gravity will counter sub-pixel movement and cause all non-attached objects to fall through the mask eventually
35  int32_t MaskRemovalY;
36 
37  class C4Object **ppAttachingObjects; // objects to be moved with mask motion
39 
40  C4TargetRect MaskPutRect; // absolute bounding screen rect at which the mask is put - tx and ty are offsets within pSolidMask (for rects outside the landscape)
41 
42  BYTE *pSolidMaskMatBuff; // material replaced by this solidmask. MCVehic if no solid mask data at this position OR another solidmask was already present during put (independent of MaskMaterial)
43 
44  BYTE MaskMaterial; // Either MCVehicle or MCHalfVehicle
45 
47 
48  // provides density within put SolidMask of an object
50  {
51  private:
52  class C4Object *pForObject;
53  C4SolidMask &rSolidMaskData;
54 
55  public:
56  DensityProvider(class C4Object *pForObject, C4SolidMask &rSolidMaskData)
57  : pForObject(pForObject), rSolidMaskData(rSolidMaskData) {}
58 
59  virtual int32_t GetDensity(int32_t x, int32_t y) const;
60  };
61  // Remove the solidmask temporarily
62  void RemoveTemporary(C4Rect where);
63  void PutTemporary(C4Rect where);
64  // Reput and update Matbuf after landscape change underneath
65  void Repair(C4Rect where);
66 
67  friend class C4Landscape;
68  friend class DensityProvider;
69 
70 public:
71  // Linked list of all solidmasks
72  static C4SolidMask * First;
73  static C4SolidMask * Last;
76 
77  void Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRestoreAttachment); // put mask to landscape
78  void Remove(bool fBackupAttachment); // remove mask from landscape
79  void Draw(C4TargetFacet &cgo); // draw the solidmask (dbg display)
80 
81  bool IsPut() { return MaskPut; }
82  C4SolidMask(C4Object *pForObject); // ctor
83  ~C4SolidMask(); // dtor
84 
85 #ifdef SOLIDMASK_DEBUG
86  static bool CheckConsistency();
87 #else
88  static bool CheckConsistency() { return true; }
89 #endif
90 
91  static void RemoveSolidMasks();
92  static void PutSolidMasks();
93 
94  static CSurface8 *LoadMaskFromFile(class C4Group &hGroup, const char *szFilename);
95 
96  void SetHalfVehicle(bool set);
97 };
98 
99 #endif
void Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRestoreAttachment)
Definition: C4SolidMask.cpp:33
int MaskPutRotation
Definition: C4SolidMask.h:29
int MatBuffPitch
Definition: C4SolidMask.h:30
void SetHalfVehicle(bool set)
static void RemoveSolidMasks()
void Remove(bool fBackupAttachment)
int iAttachingObjectsCapacity
Definition: C4SolidMask.h:38
void PutTemporary(C4Rect where)
int iAttachingObjectsCount
Definition: C4SolidMask.h:38
C4Object * pForObject
Definition: C4SolidMask.h:46
Definition: C4Rect.h:29
uint8_t BYTE
C4TargetRect MaskPutRect
Definition: C4SolidMask.h:40
Definition: C4Real.h:58
void RemoveTemporary(C4Rect where)
void Draw(C4TargetFacet &cgo)
void Repair(C4Rect where)
virtual int32_t GetDensity(int32_t x, int32_t y) const
bool IsPut()
Definition: C4SolidMask.h:81
class C4Object ** ppAttachingObjects
Definition: C4SolidMask.h:37
static bool CheckConsistency()
Definition: C4SolidMask.h:88
DensityProvider(class C4Object *pForObject, C4SolidMask &rSolidMaskData)
Definition: C4SolidMask.h:56
static C4SolidMask * First
Definition: C4SolidMask.h:72
C4Real MaskRemovalX
Definition: C4SolidMask.h:34
C4SolidMask(C4Object *pForObject)
bool MaskPut
Definition: C4SolidMask.h:28
BYTE * pSolidMaskMatBuff
Definition: C4SolidMask.h:42
C4SolidMask * Prev
Definition: C4SolidMask.h:74
static CSurface8 * LoadMaskFromFile(class C4Group &hGroup, const char *szFilename)
static void PutSolidMasks()
static C4SolidMask * Last
Definition: C4SolidMask.h:73
BYTE MaskMaterial
Definition: C4SolidMask.h:44
C4SolidMask * Next
Definition: C4SolidMask.h:75
int32_t MaskRemovalY
Definition: C4SolidMask.h:35