summaryrefslogtreecommitdiff
path: root/src/KingSystem/Physics/physHeapUtil.h
blob: 06890a95f8b21a8d280c9c828d522aa96f7eebd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once

#include <Havok/Common/Base/Object/hkReferencedObject.h>

namespace ksys::phys {

template <typename T>
inline std::enable_if_t<std::is_base_of_v<hkReferencedObject, T>, void>
deleteRefCountedHavokObject(T*& object) {
    if (!object)
        return;

    /// @bug This should just be a delete expression. Decrementing the reference count
    /// n times (with n = the reference count) is not how reference counting is supposed to work.
    for (int i = 0, n = object->getReferenceCount(); i < n; ++i)
        object->removeReference();

    object = nullptr;
}

}  // namespace ksys::phys