All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4SolidMask::DensityProvider Class Reference

#include <C4SolidMask.h>

Inheritance diagram for C4SolidMask::DensityProvider:
Collaboration diagram for C4SolidMask::DensityProvider:

Public Member Functions

 DensityProvider (class C4Object *pForObject, C4SolidMask &rSolidMaskData)
int32_t GetDensity (int32_t x, int32_t y) const override

Detailed Description

Definition at line 49 of file C4SolidMask.h.

Constructor & Destructor Documentation

C4SolidMask::DensityProvider::DensityProvider ( class C4Object pForObject,
C4SolidMask rSolidMaskData 

Definition at line 56 of file C4SolidMask.h.

57  : pForObject(pForObject), rSolidMaskData(rSolidMaskData) {}

Member Function Documentation

int32_t C4SolidMask::DensityProvider::GetDensity ( int32_t  x,
int32_t  y 
) const

Reimplemented from C4DensityProvider.

Definition at line 208 of file C4SolidMask.cpp.

References CSurface8::_GetPix(), C4M_Vehicle, C4Object::Def, C4Rect::Hgt, IsSomeVehicle(), C4SolidMask::MaskPutRect, C4SolidMask::MaskPutRotation, C4SolidMask::MatBuffPitch, C4SolidMask::pForObject, C4Def::pSolidMask, C4SolidMask::pSolidMaskMatBuff, C4Object::SolidMask, C4TargetRect::tx, C4TargetRect::ty, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

209 {
210  // outside SolidMask: free
211  x -= rSolidMaskData.MaskPutRect.x;
212  y -= rSolidMaskData.MaskPutRect.y;
213  if (!Inside<int32_t>(x, 0, rSolidMaskData.MaskPutRect.Wdt-1)
214  || !Inside<int32_t>(y, 0, rSolidMaskData.MaskPutRect.Hgt-1))
215  return 0;
216  // check put mask. Easy for unrotated
217  BYTE pix;
218  if (!rSolidMaskData.MaskPutRotation)
219  {
220  CSurface8 *pSolidMask = rSolidMaskData.pForObject->Def->pSolidMask;
221  if (!pSolidMask) return 0; // can't really happen
222  pix=pSolidMask->_GetPix(x+rSolidMaskData.pForObject->SolidMask.x+rSolidMaskData.MaskPutRect.tx,
223  y+rSolidMaskData.pForObject->SolidMask.y+rSolidMaskData.MaskPutRect.ty);
224  if (pix == 0xff)
225  return C4M_Vehicle;
226  else
227  return 0;
228  }
229  else
230  {
231  // Using put-buffer for rotated masks
232  // for SolidMask-pixels not put because there was another SolidMask already, this will not return solid
233  pix=*(rSolidMaskData.pSolidMaskMatBuff+(y+rSolidMaskData.MaskPutRect.ty)*rSolidMaskData.MatBuffPitch+rSolidMaskData.MaskPutRect.tx+x);
234  if (IsSomeVehicle(pix))
235  return 0;
236  else
237  return C4M_Vehicle;
238  }
239 }
int MaskPutRotation
Definition: C4SolidMask.h:29
const int32_t C4M_Vehicle
Definition: C4Constants.h:171
int MatBuffPitch
Definition: C4SolidMask.h:30
CSurface8 * pSolidMask
Definition: C4Def.h:192
BYTE _GetPix(int x, int y) const
Definition: CSurface8.h:54
C4Object * pForObject
Definition: C4SolidMask.h:46
uint8_t BYTE
C4TargetRect MaskPutRect
Definition: C4SolidMask.h:40
int32_t Wdt
Definition: C4Rect.h:30
C4Def * Def
Definition: C4Object.h:143
int32_t y
Definition: C4Rect.h:30
int32_t tx
Definition: C4Rect.h:79
int32_t ty
Definition: C4Rect.h:79
int32_t x
Definition: C4Rect.h:30
int32_t Hgt
Definition: C4Rect.h:30
bool IsSomeVehicle(BYTE mat)
Definition: C4Material.h:226
BYTE * pSolidMaskMatBuff
Definition: C4SolidMask.h:42
C4TargetRect SolidMask
Definition: C4Object.h:150

Here is the call graph for this function:

The documentation for this class was generated from the following files: