Init Repo
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#include "CreatePrimCommand.h"
|
||||
#include "../../utils/Logger.h"
|
||||
#include <pxr/usd/usd/prim.h>
|
||||
|
||||
namespace UsdLayerManager {
|
||||
|
||||
CreatePrimCommand::CreatePrimCommand(pxr::UsdStageRefPtr stage,
|
||||
const pxr::SdfPath& primPath,
|
||||
const pxr::TfToken& typeName)
|
||||
: m_stage(stage)
|
||||
, m_primPath(primPath)
|
||||
, m_typeName(typeName)
|
||||
, m_description("Create " + typeName.GetString() + " " + primPath.GetString())
|
||||
{
|
||||
}
|
||||
|
||||
void CreatePrimCommand::Execute() {
|
||||
if (!m_stage) return;
|
||||
try {
|
||||
pxr::UsdPrim prim = m_stage->DefinePrim(m_primPath, m_typeName);
|
||||
if (!prim.IsValid())
|
||||
LOG_ERROR("CreatePrimCommand: failed to define prim " + m_primPath.GetString());
|
||||
} catch (const std::exception& e) {
|
||||
LOG_ERROR(std::string("CreatePrimCommand::Execute error: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void CreatePrimCommand::Undo() {
|
||||
if (!m_stage) return;
|
||||
try {
|
||||
if (!m_stage->RemovePrim(m_primPath))
|
||||
LOG_ERROR("CreatePrimCommand: failed to remove prim " + m_primPath.GetString());
|
||||
} catch (const std::exception& e) {
|
||||
LOG_ERROR(std::string("CreatePrimCommand::Undo error: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace UsdLayerManager
|
||||
Reference in New Issue
Block a user