本文整理汇总了C++中Identifier::ObjectType方法的典型用法代码示例。如果您正苦于以下问题:C++ Identifier::ObjectType方法的具体用法?C++ Identifier::ObjectType怎么用?C++ Identifier::ObjectType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Identifier
的用法示例。
在下文中一共展示了Identifier::ObjectType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetParent
bool RetainedEntityInterface::SetParent(
const Identifier& child, const Identifier& parent, int insertionPosition)
{
if (child.Document() != parent.Document())
return false;
auto childType = _scene->GetObjectType(child.ObjectType());
if (!childType) return false;
auto* childObj = _scene->GetEntityInt(child.Document(), child.Object());
if (!childObj || childObj->_type != child.ObjectType())
return false;
if (childObj->_parent != 0) {
auto* oldParent = _scene->GetEntityInt(child.Document(), childObj->_parent);
if (oldParent) {
auto i = std::find(oldParent->_children.begin(), oldParent->_children.end(), child.Object());
oldParent->_children.erase(i);
auto oldParentType = _scene->GetObjectType(parent.ObjectType());
if (oldParentType)
_scene->InvokeOnChange(
*oldParentType, *oldParent,
RetainedEntities::ChangeType::RemoveChild);
}
childObj->_parent = 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// if parent is set to 0, then this is a "remove from parent" operation
if (!parent.Object()) {
_scene->InvokeOnChange(*childType, *childObj, RetainedEntities::ChangeType::SetParent);
return true;
}
auto* parentObj = _scene->GetEntityInt(parent.Document(), parent.Object());
if (!parentObj || parentObj->_type != parent.ObjectType()) {
_scene->InvokeOnChange(*childType, *childObj, RetainedEntities::ChangeType::SetParent);
return false;
}
if (insertionPosition < 0 || insertionPosition >= (int)parentObj->_children.size()) {
parentObj->_children.push_back(child.Object());
} else {
parentObj->_children.insert(
parentObj->_children.begin() + insertionPosition,
child.Object());
}
childObj->_parent = parentObj->_id;
_scene->InvokeOnChange(*childType, *childObj, RetainedEntities::ChangeType::SetParent);
auto parentType = _scene->GetObjectType(parent.ObjectType());
if (parentType)
_scene->InvokeOnChange(*parentType, *parentObj, RetainedEntities::ChangeType::AddChild);
return true;
}
示例2: DeleteObject
bool RetainedEntityInterface::DeleteObject(const Identifier& id)
{
for (auto i=_scene->_objects.begin(); i!=_scene->_objects.end(); ++i)
if (i->_doc == id.Document() && i->_id == id.Object()) {
assert(i->_type == id.ObjectType());
RetainedEntity copy(std::move(*i));
_scene->_objects.erase(i);
auto type = _scene->GetObjectType(id.ObjectType());
if (type)
_scene->InvokeOnChange(*type, copy, RetainedEntities::ChangeType::Delete);
return true;
}
return false;
}
示例3: DeleteObject
bool TerrainEntities::DeleteObject(
const Identifier& id)
{
if (id.ObjectType() == ObjectType_Terrain) {
_uberSurfaceDir = ::Assets::rstring();
return true;
}
return false;
}
示例4: SetProperty
bool TerrainEntities::SetProperty(
const Identifier& id,
const PropertyInitializer initializers[], size_t initializerCount)
{
if (id.ObjectType() == ObjectType_Terrain) {
for (size_t c=0; c<initializerCount; ++c)
SetTerrainProperty(initializers[c]);
return true;
}
return false;
}
示例5: CreateObject
bool TerrainEntities::CreateObject(
const Identifier& id,
const PropertyInitializer initializers[], size_t initializerCount)
{
if (id.ObjectType() == ObjectType_Terrain) {
_terrainManager->SetWorldSpaceOrigin(Float3(0.f, 0.f, 0.f));
for (size_t c=0; c<initializerCount; ++c)
SetTerrainProperty(initializers[c]);
return true;
}
return false;
}
示例6: CreateObject
bool RetainedEntityInterface::CreateObject(const Identifier& id,
const PropertyInitializer initializers[], size_t initializerCount)
{
auto type = _scene->GetObjectType(id.ObjectType());
if (!type) return false;
for (auto i=_scene->_objects.cbegin(); i!=_scene->_objects.cend(); ++i)
if (i->_doc == id.Document() && i->_id == id.Object()) return false;
RetainedEntity newObject;
newObject._doc = id.Document();
newObject._id = id.Object();
newObject._type = id.ObjectType();
newObject._parent = 0;
for (size_t c=0; c<initializerCount; ++c)
_scene->SetSingleProperties(newObject, *type, initializers[c]);
_scene->_objects.push_back(std::move(newObject));
_scene->InvokeOnChange(*type, _scene->_objects[_scene->_objects.size()-1], RetainedEntities::ChangeType::Create);
return true;
}
示例7: GetProperty
bool RetainedEntityInterface::GetProperty(const Identifier& id, PropertyId prop, void* dest, unsigned* destSize) const
{
auto type = _scene->GetObjectType(id.ObjectType());
if (!type) return false;
if (prop == 0 || prop > type->_properties.size()) return false;
const auto& propertyName = type->_properties[prop-1];
for (auto i=_scene->_objects.begin(); i!=_scene->_objects.end(); ++i)
if (i->_doc == id.Document() && i->_id == id.Object()) {
auto res = i->_properties.GetParameter<unsigned>(propertyName.c_str());
if (res.first) {
*(unsigned*)dest = res.second;
}
return true;
}
return false;
}
示例8: SetProperty
bool RetainedEntityInterface::SetProperty(
const Identifier& id,
const PropertyInitializer initializers[], size_t initializerCount)
{
auto type = _scene->GetObjectType(id.ObjectType());
if (!type) return false;
for (auto i=_scene->_objects.begin(); i!=_scene->_objects.end(); ++i)
if (i->_doc == id.Document() && i->_id == id.Object()) {
bool gotChange = false;
for (size_t c=0; c<initializerCount; ++c) {
auto& prop = initializers[c];
gotChange |= _scene->SetSingleProperties(*i, *type, prop);
}
if (gotChange) _scene->InvokeOnChange(*type, *i, RetainedEntities::ChangeType::SetProperty);
return true;
}
return false;
}