re3/src/modelinfo/BaseModelInfo.cpp

102 lines
1.4 KiB
C++
Raw Normal View History

2019-05-15 14:52:37 +00:00
#include "common.h"
2020-04-17 13:31:11 +00:00
2019-05-15 14:52:37 +00:00
#include "templates.h"
#include "TxdStore.h"
#include "2dEffect.h"
#include "BaseModelInfo.h"
2020-05-05 12:13:09 +00:00
CBaseModelInfo::CBaseModelInfo(ModelInfoType type)
2019-05-15 14:52:37 +00:00
{
m_colModel = nil;
2019-06-30 10:53:39 +00:00
m_twodEffects = nil;
2019-05-15 14:52:37 +00:00
m_objectId = -1;
m_refCount = 0;
m_txdSlot = -1;
m_type = type;
m_num2dEffects = 0;
m_freeCol = false;
}
void
CBaseModelInfo::Shutdown(void)
{
DeleteCollisionModel();
DeleteRwObject();
2019-06-30 10:53:39 +00:00
m_twodEffects = nil;
2019-05-15 14:52:37 +00:00
m_num2dEffects = 0;
m_txdSlot = -1;
}
void
CBaseModelInfo::DeleteCollisionModel(void)
{
if(m_colModel && m_freeCol){
if(m_colModel)
delete m_colModel;
m_colModel = nil;
}
}
void
CBaseModelInfo::AddRef(void)
{
m_refCount++;
AddTexDictionaryRef();
}
void
CBaseModelInfo::RemoveRef(void)
{
m_refCount--;
RemoveTexDictionaryRef();
}
void
CBaseModelInfo::SetTexDictionary(const char *name)
{
int slot = CTxdStore::FindTxdSlot(name);
if(slot < 0)
slot = CTxdStore::AddTxdSlot(name);
m_txdSlot = slot;
}
void
CBaseModelInfo::AddTexDictionaryRef(void)
{
CTxdStore::AddRef(m_txdSlot);
}
void
CBaseModelInfo::RemoveTexDictionaryRef(void)
{
CTxdStore::RemoveRef(m_txdSlot);
}
void
CBaseModelInfo::Init2dEffects(void)
{
m_twodEffects = nil;
m_num2dEffects = 0;
}
void
CBaseModelInfo::Add2dEffect(C2dEffect *fx)
{
if(m_twodEffects)
m_num2dEffects++;
else{
m_twodEffects = fx;
m_num2dEffects = 1;
}
}
C2dEffect*
CBaseModelInfo::Get2dEffect(int n)
{
if(m_twodEffects)
return &m_twodEffects[n];
else
return nil;
}