Change getContactLayerBaseRelativeValue to return an int to avoid casts

This commit is contained in:
Léo Lam 2022-03-17 22:54:03 +01:00
parent e7e9644a1f
commit 8d88461c52
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 6 additions and 6 deletions

View File

@ -74,12 +74,12 @@ inline void CollisionInfoBase::enableLayer(ContactLayer layer) {
}
inline void CollisionInfoBase::disableLayer(ContactLayer layer) {
getLayerMask(getContactLayerType(layer)).resetBit(int(getContactLayerBaseRelativeValue(layer)));
getLayerMask(getContactLayerType(layer)).resetBit(getContactLayerBaseRelativeValue(layer));
}
inline bool CollisionInfoBase::isLayerEnabled(ContactLayer layer) const {
const auto& mask = getLayerMask(getContactLayerType(layer));
return mask.isOnBit(int(getContactLayerBaseRelativeValue(layer)));
return mask.isOnBit(getContactLayerBaseRelativeValue(layer));
}
inline void CollisionInfoBase::lock() {

View File

@ -41,13 +41,13 @@ public:
bool isLayerSubscribed(ContactLayer layer) const {
const auto type = getContactLayerType(layer);
return mSubscribedLayers[int(type)].isOnBit(int(getContactLayerBaseRelativeValue(layer)));
return mSubscribedLayers[int(type)].isOnBit(getContactLayerBaseRelativeValue(layer));
}
// TODO: rename
bool isLayerInMask2(ContactLayer layer) const {
const auto type = getContactLayerType(layer);
return mLayerMask2[int(type)].isOnBit(int(getContactLayerBaseRelativeValue(layer)));
return mLayerMask2[int(type)].isOnBit(getContactLayerBaseRelativeValue(layer));
}
void setLayerMasks(const LayerMaskBuilder& builder) {

View File

@ -20,7 +20,7 @@ u32 getContactLayerBase(ContactLayerType type) {
return FirstSensor;
}
u32 getContactLayerBaseRelativeValue(ContactLayer layer) {
int getContactLayerBaseRelativeValue(ContactLayer layer) {
return layer - (layer < FirstSensor ? FirstEntity : FirstSensor);
}

View File

@ -378,7 +378,7 @@ union SensorQueryCollisionMask {
ContactLayerType getContactLayerType(ContactLayer layer);
u32 makeContactLayerMask(ContactLayer layer);
u32 getContactLayerBase(ContactLayerType type);
u32 getContactLayerBaseRelativeValue(ContactLayer layer);
int getContactLayerBaseRelativeValue(ContactLayer layer);
const char* contactLayerToText(ContactLayer layer);
ContactLayer contactLayerFromText(const sead::SafeString& text);