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)
virtual int32_t GetDensity (int32_t x, int32_t y) const

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 209 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.

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