metaforce/Runtime/Collision/CMaterialList.hpp

163 lines
3.5 KiB
C++
Raw Normal View History

2016-04-19 00:17:49 +00:00
#ifndef __URDE_CMATERIALLIST_HPP__
#define __URDE_CMATERIALLIST_HPP__
#include "RetroTypes.hpp"
namespace urde
{
2016-04-22 20:22:45 +00:00
enum class EMaterialTypes
{
2016-12-29 21:38:59 +00:00
Unknown = 0,
Stone = 1,
Metal = 2,
Grass = 3,
Ice = 4,
Pillar = 5,
MetalGrating = 6,
Phazon = 7,
Dirt = 8,
Lava = 9,
2016-04-22 20:22:45 +00:00
Ten = 10,
2016-12-29 21:38:59 +00:00
Snow = 11,
MudSlow = 12,
HalfPipe = 13,
Mud = 14,
Glass = 15,
Shield = 16,
Sand = 17,
ProjectilePassthrough = 18,
Solid = 19,
Twenty = 20,
2016-12-29 21:38:59 +00:00
CameraPassthrough = 21,
Wood = 22,
Organic = 23,
TwentyFour = 24,
RedundantEdgeOrFlippedTri = 25,
SeeThrough = 26,
ScanPassthrough = 27,
AIPassthrough = 28,
Ceiling = 29,
Wall = 30,
Floor = 31,
Player = 32,
Character = 33,
Trigger = 34,
Projectile = 35,
Bomb = 36,
2016-12-29 21:38:59 +00:00
GroundCollider = 37,
2017-07-23 23:45:04 +00:00
NoStaticCollision = 38,
2016-12-29 21:38:59 +00:00
Scannable = 39,
Target = 40,
Orbit = 41,
Occluder = 42,
Immovable = 43,
Debris = 44,
PowerBomb = 45,
Unknown46 = 46,
CollisionActor = 47,
2016-12-29 21:38:59 +00:00
AIBlock = 48,
Platform = 49,
NonSolidDamageable = 50,
2017-04-07 05:35:09 +00:00
RadarObject = 51,
PlatformSlave = 52,
2017-02-11 00:52:52 +00:00
Unknown54 = 54,
2017-06-21 07:24:26 +00:00
SolidCharacter = 55,
2016-12-29 21:38:59 +00:00
ExcludeFromLineOfSightTest = 56,
2017-04-07 05:35:09 +00:00
ExcludeFromRadar = 57,
2017-06-21 07:24:26 +00:00
NoPlayerCollision = 58,
2016-04-22 20:22:45 +00:00
SixtyThree = 63
};
2016-04-19 00:17:49 +00:00
class CMaterialList
{
2016-04-22 20:22:45 +00:00
friend class CMaterialFilter;
2016-07-25 17:58:47 +00:00
u64 x0_list = 0;
2016-04-22 20:22:45 +00:00
public:
2016-04-19 00:17:49 +00:00
CMaterialList() = default;
2016-07-25 17:58:47 +00:00
CMaterialList(u64 flags) : x0_list(flags) {}
2016-04-22 20:22:45 +00:00
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5, EMaterialTypes t6)
: CMaterialList(t1, t2, t3, t4, t5)
2016-07-25 17:58:47 +00:00
{ x0_list = 1ull << u64(t6); }
2016-04-22 20:22:45 +00:00
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5)
: CMaterialList(t1, t2, t3, t4)
2016-07-25 17:58:47 +00:00
{ x0_list = 1ull << u64(t5); }
2016-04-22 20:22:45 +00:00
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4)
: CMaterialList(t1, t2, t3)
2016-07-25 17:58:47 +00:00
{ x0_list = 1ull << u64(t4); }
2016-04-22 20:22:45 +00:00
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3)
: CMaterialList(t1, t2)
2016-07-25 17:58:47 +00:00
{ x0_list = 1ull << u64(t3); }
2016-04-22 20:22:45 +00:00
CMaterialList(EMaterialTypes t1, EMaterialTypes t2)
: CMaterialList(t1)
2016-07-25 17:58:47 +00:00
{ x0_list = 1ull << u64(t2); }
2016-04-22 20:22:45 +00:00
CMaterialList(EMaterialTypes t1)
2016-07-25 17:58:47 +00:00
: x0_list(1ull << u64(t1))
2016-04-22 20:22:45 +00:00
{
}
2017-06-26 01:36:31 +00:00
u64 GetValue() const { return x0_list; }
2016-09-16 22:21:19 +00:00
static s32 BitPosition(u64 flag)
2016-04-22 20:22:45 +00:00
{
2016-07-26 22:45:01 +00:00
for (u32 i = 0; i < 63; ++i)
if ((flag & (1ull << i)) != 0)
return i;
2016-04-22 20:22:45 +00:00
return -1;
}
void Add(EMaterialTypes type)
{
2017-02-03 23:32:15 +00:00
x0_list |= (1ull << u32(type));
2016-04-22 20:22:45 +00:00
}
2017-03-26 04:12:06 +00:00
void Add(const CMaterialList& l)
{
x0_list |= l.x0_list;
}
2016-04-22 20:22:45 +00:00
void Remove(EMaterialTypes type)
{
2017-02-03 23:32:15 +00:00
x0_list &= ~(1ull << u32(type));
2016-04-22 20:22:45 +00:00
}
void Remove(const CMaterialList& other)
{
2016-07-25 17:58:47 +00:00
x0_list &= ~(other.x0_list);
2016-04-22 20:22:45 +00:00
}
2016-12-26 07:58:44 +00:00
bool HasMaterial(EMaterialTypes type) const
2016-04-22 20:22:45 +00:00
{
2017-02-03 23:32:15 +00:00
return (x0_list & (1ull << u32(type))) != 0;
2016-04-22 20:22:45 +00:00
}
bool SharesMaterials(const CMaterialList& other)
{
for (u32 i = 0; i < 64; i++)
{
2016-07-25 17:58:47 +00:00
if ((x0_list & (1ull << i)) != 0 && (other.x0_list & (1ull << i)) != 0)
2016-04-22 20:22:45 +00:00
return true;
}
return false;
}
2016-12-29 21:38:59 +00:00
u64 Intersection(const CMaterialList& other) const
{
return other.x0_list & x0_list;
}
2017-06-19 07:00:50 +00:00
u64 XOR(const CMaterialList& other) const
{
return x0_list ^ other.x0_list;
}
2016-04-19 00:17:49 +00:00
};
}
#endif // __URDE_CMATERIALLIST_HPP__