Units: SIN's collision height fix as he wrote it

SIN's fix for creature models whose client data stores a negative
'unset' collision height (-20000000, model 34 and others): such a model
now gets the default collision height (2.03128), and a mount height
that is not set is ignored. Some raptors' melee swings failed the line
of sight check because of it.

This replaces our fix for the same bug, which took the top of the
model's bounding box instead (CreatureModelDataEntry::GetCollisionHeight,
removed). For those 68 models the height is now the default, not the
model's own.

Code by SIN (1amcoff1n), Invalid creature collision heights for 0.1.35.
Applied as written; only the hunk position differs in our Unit.cpp. To build,
the bot module's collisionprobe command now prints the raw model height
(it called the removed helper).
This commit is contained in:
Karrz1
2026-11-16 20:48:01 +00:00
parent 8d6d861814
commit 511ddb39c0
2 changed files with 11 additions and 22 deletions
-10
View File
@@ -1183,16 +1183,6 @@ struct CreatureModelDataEntry
EnumFlag<CreatureModelDataFlags> GetFlags() const { return static_cast<CreatureModelDataFlags>(Flags); }
// Classic 1.60 client data: 67 models (142 displays, for example the Deviate Creeper's) carry -20000000 in CollisionHeight and
// CollisionWidth, a "not set" mark the client fills from the model's own bounds. Taken as a height it put those creatures' head
// 14 million yards under the ground, so nothing could see them (bots 0.1 y from a Deviate Creeper read "out of line of sight",
// Discord 2026-11-09). The top of the model's bounding box (GeoBox[5]) is the height then; 0 when that is not above the feet.
float GetCollisionHeight() const
{
if (CollisionHeight >= 0.0f)
return CollisionHeight;
return GeoBox[5] > 0.0f ? GeoBox[5] : 0.0f;
}
};
struct CreatureTypeEntry
+11 -12
View File
@@ -15329,31 +15329,30 @@ bool Unit::VisibleAuraSlotCompare::operator()(AuraApplication* left, AuraApplica
return left->GetSlot() < right->GetSlot();
}
// Returns collisionheight of the unit. If it is 0, it returns DEFAULT_COLLISION_HEIGHT.
float Unit::GetCollisionHeight() const
{
float scaleMod = GetObjectScale(); // 99% sure about this
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId());
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelID);
// Client models can store a negative sentinel for an unset collision height.
if (!std::isfinite(modelData->CollisionHeight) || modelData->CollisionHeight <= 0.0f)
return DEFAULT_COLLISION_HEIGHT;
float const scaleMod = GetObjectScale();
float collisionHeight = scaleMod * modelData->CollisionHeight * modelData->ModelScale * displayInfo->CreatureModelScale;
if (IsMounted())
{
if (CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetMountDisplayId()))
{
if (CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelID))
{
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId());
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelID);
float const collisionHeight = scaleMod * ((mountModelData->MountHeight * mountDisplayInfo->CreatureModelScale) + (modelData->GetCollisionHeight() * modelData->ModelScale * displayInfo->CreatureModelScale * 0.5f));
return collisionHeight == 0.0f ? DEFAULT_COLLISION_HEIGHT : collisionHeight;
if (std::isfinite(mountModelData->MountHeight) && mountModelData->MountHeight >= 0.0f)
collisionHeight = scaleMod * ((mountModelData->MountHeight * mountDisplayInfo->CreatureModelScale) + (modelData->CollisionHeight * modelData->ModelScale * displayInfo->CreatureModelScale * 0.5f));
}
}
}
//! Dismounting case - use basic default model data
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId());
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelID);
float const collisionHeight = scaleMod * modelData->GetCollisionHeight() * modelData->ModelScale * displayInfo->CreatureModelScale;
return collisionHeight == 0.0f ? DEFAULT_COLLISION_HEIGHT : collisionHeight;
return std::isfinite(collisionHeight) && collisionHeight > 0.0f ? collisionHeight : DEFAULT_COLLISION_HEIGHT;
}
void Unit::AddWorldEffect(int32 worldEffectId)