allow null parent to setParent
This commit is contained in:
@@ -81,20 +81,30 @@ extern "C"
|
|||||||
const auto child = Entity::import(childId);
|
const auto child = Entity::import(childId);
|
||||||
const auto parent = Entity::import(parentId);
|
const auto parent = Entity::import(parentId);
|
||||||
|
|
||||||
const auto &parentInstance = tm->getInstance(parent);
|
|
||||||
const auto &childInstance = tm->getInstance(child);
|
const auto &childInstance = tm->getInstance(child);
|
||||||
|
|
||||||
|
if (!childInstance.isValid())
|
||||||
|
{
|
||||||
|
Log("Child instance is not valid");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parent.isNull()) {
|
||||||
|
Log("Unparenting child instance");
|
||||||
|
tm->setParent(childInstance, TransformManager::Instance());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto &parentInstance = tm->getInstance(parent);
|
||||||
|
|
||||||
if (!parentInstance.isValid())
|
if (!parentInstance.isValid())
|
||||||
{
|
{
|
||||||
Log("Parent instance is not valid");
|
Log("Parent instance is not valid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!childInstance.isValid())
|
|
||||||
{
|
|
||||||
Log("Child instance is not valid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preserveScaling)
|
if (preserveScaling)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user