Clipmask: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
Fixed: sprites and walls were swapped.
Fox (talk | contribs)
No edit summary
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Clipmask is a mask that tells whether the object should be clipped to or not. The lower 16 bits are anded with [[cstat(wall)|cstat of wall]] and the higher 16 bits are anded with [[cstat|cstat of sprite]]. Clipmask is used by the [[getzrange]] and [[hitscan]] commands.
Clipmask is a value that tells what kinds of objects should be clipped or not. The lower 16 bits are anded (&) with the [[cstat (wall)|cstat of a wall]] and the higher 16 bits are anded with the [[cstat (sprite)|cstat of a sprite]]. Clipmask is used by the [[getzrange]], [[hitscan]], and [[movesprite]] commands.


One can calculate a mask using this formula:


One can calculate a mask using this formula:<br>
  clipmask=(sprite_cstat*65536)+wall_cstat
  clipmask=(sprite_cstat*65536)+wall_cstat<br>
[[cstat|sprite_cstat]] and [[cstat(wall)|wall_cstat]] should have only set the bits which should be clipped.
The most important bits are blockable(flag 1), hitable(flag 64 for walls and 256 for sprites), masking wall(flag 16).


The game has two predefined clipmasks: CLIPMASK0 and CLIPMASK1<br>
[[cstat (sprite)|sprite_cstat]] and [[cstat (wall)|wall_cstat]] should have only set the bits which should be clipped.  
CLIPMASK0 = (1*65536)+1 = 1 0001h<br>
This clips to blockable sprites(flag 1) and walls(flag 1).<br>


CLIPMASK1 = (256*65536)+64 = 100 0040h<br>
The most important bits are blockable (flag 1), hitable (flag 64 for walls and 256 for sprites), masking wall (flag 16).
This clips to hitable sprites(flag 256) and walls(flag 64).<br>


  Recommend clipmask for hitscan 4294901808) = FFFF 0030h<br>
== Pre-defined values ===
This clips sprites which have any flags and walls which are one-sided or masking..
 
The game has two predefined clipmasks: CLIPMASK0 and CLIPMASK1. Apparently the first one is used by regular actors, while the second is for projectiles.
 
CLIPMASK0 = (1*65536)+1 = 1 0001h
 
This clips to blocking sprites (flag 1) and walls (flag 1).
 
  CLIPMASK1 = (256*65536)+64 = 100 0040h
 
== Examples ==
 
This clips to sprites that can be hit by (hitscan) weapons (flag 256) and walls (flag 64).
 
Sample clipmask for [[hitscan]] (4294901808) = FFFF 0030h
 
This clips sprites which have any flags and walls which are one-sided or masking.
[[Category:Bitfields]]

Latest revision as of 10:48, 22 February 2020

Clipmask is a value that tells what kinds of objects should be clipped or not. The lower 16 bits are anded (&) with the cstat of a wall and the higher 16 bits are anded with the cstat of a sprite. Clipmask is used by the getzrange, hitscan, and movesprite commands.

One can calculate a mask using this formula:

clipmask=(sprite_cstat*65536)+wall_cstat

sprite_cstat and wall_cstat should have only set the bits which should be clipped.

The most important bits are blockable (flag 1), hitable (flag 64 for walls and 256 for sprites), masking wall (flag 16).

Pre-defined values =

The game has two predefined clipmasks: CLIPMASK0 and CLIPMASK1. Apparently the first one is used by regular actors, while the second is for projectiles.

CLIPMASK0 = (1*65536)+1 = 1 0001h

This clips to blocking sprites (flag 1) and walls (flag 1).

CLIPMASK1 = (256*65536)+64 = 100 0040h

Examples

This clips to sprites that can be hit by (hitscan) weapons (flag 256) and walls (flag 64).

Sample clipmask for hitscan (4294901808) = FFFF 0030h

This clips sprites which have any flags and walls which are one-sided or masking.