Init Repo

This commit is contained in:
2026-06-03 09:00:11 +08:00
commit 9be48d8b9e
155 changed files with 14827 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
#include "TransformCommand.h"
#include "../../utils/Logger.h"
#include <pxr/usd/usd/editContext.h>
namespace UsdLayerManager {
TransformCommand::TransformCommand(pxr::UsdStageRefPtr stage,
const pxr::SdfPath& primPath,
pxr::SdfLayerHandle editLayer,
const pxr::GfVec3d& oldTranslate,
const pxr::GfVec3f& oldRotate,
const pxr::GfVec3f& oldScale,
const pxr::GfVec3d& newTranslate,
const pxr::GfVec3f& newRotate,
const pxr::GfVec3f& newScale,
pxr::UsdGeomXformCommonAPI::RotationOrder rotOrder,
std::string description)
: m_stage(stage)
, m_primPath(primPath)
, m_editLayer(editLayer)
, m_oldTranslate(oldTranslate)
, m_oldRotate(oldRotate)
, m_oldScale(oldScale)
, m_newTranslate(newTranslate)
, m_newRotate(newRotate)
, m_newScale(newScale)
, m_rotOrder(rotOrder)
, m_description(std::move(description))
{
}
void TransformCommand::Execute() {
Apply(m_newTranslate, m_newRotate, m_newScale);
}
void TransformCommand::Undo() {
Apply(m_oldTranslate, m_oldRotate, m_oldScale);
}
void TransformCommand::Apply(const pxr::GfVec3d& t,
const pxr::GfVec3f& r,
const pxr::GfVec3f& s)
{
if (!m_stage || m_primPath.IsEmpty()) return;
pxr::UsdPrim prim = m_stage->GetPrimAtPath(m_primPath);
if (!prim) return;
pxr::UsdGeomXformCommonAPI api(prim);
if (!api) return;
try {
if (m_editLayer) {
pxr::UsdEditContext ec(m_stage, m_editLayer);
api.SetTranslate(t, pxr::UsdTimeCode::Default());
api.SetRotate(r, m_rotOrder, pxr::UsdTimeCode::Default());
api.SetScale(s, pxr::UsdTimeCode::Default());
} else {
api.SetTranslate(t, pxr::UsdTimeCode::Default());
api.SetRotate(r, m_rotOrder, pxr::UsdTimeCode::Default());
api.SetScale(s, pxr::UsdTimeCode::Default());
}
} catch (const std::exception& e) {
LOG_ERROR(std::string("TransformCommand::Apply error: ") + e.what());
}
}
} // namespace UsdLayerManager