Skip to content

Commit

Permalink
fix MotionInstance move
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Oct 22, 2024
1 parent 9011b17 commit 8c755dc
Showing 1 changed file with 70 additions and 65 deletions.
135 changes: 70 additions & 65 deletions include/luisa/runtime/rtx/motion_instance.h
Original file line number Diff line number Diff line change
@@ -1,65 +1,70 @@
//
// Created by Mike on 2024/9/21.
//

#pragma once

#include <luisa/runtime/device.h>

namespace luisa::compute {

class Curve;
class Mesh;
class ProceduralPrimitive;

class LC_RUNTIME_API MotionInstance : public Resource {

friend class Device;

private:
uint64_t _child_handle;
AccelMotionMode _mode;
luisa::vector<MotionInstanceTransform> _transform_keyframes;

private:
// for internal use only; does not have linkages
MotionInstance(DeviceInterface *device,
const Resource &resource,
const AccelMotionOption &option) noexcept;

private:
MotionInstance(DeviceInterface *device,
const Mesh &mesh,
const AccelMotionOption &option) noexcept;

MotionInstance(DeviceInterface *device,
const Curve &curve,
const AccelMotionOption &option) noexcept;

MotionInstance(DeviceInterface *device,
const ProceduralPrimitive &primitive,
const AccelMotionOption &option) noexcept;

public:
void set_keyframe(size_t index, const MotionInstanceTransform &transform) noexcept;
void set_keyframe(size_t index, const MotionInstanceTransformMatrix &transform) noexcept;
void set_keyframe(size_t index, const MotionInstanceTransformSRT &transform) noexcept;
void set_keyframes(luisa::span<const MotionInstanceTransform> transforms) noexcept;
void set_keyframes(luisa::span<const MotionInstanceTransformMatrix> transforms) noexcept;
void set_keyframes(luisa::span<const MotionInstanceTransformSRT> transforms) noexcept;

[[nodiscard]] const MotionInstanceTransform &keyframe(size_t index) const noexcept;
[[nodiscard]] const MotionInstanceTransformMatrix &keyframe_matrix(size_t index) const noexcept;
[[nodiscard]] const MotionInstanceTransformSRT &keyframe_srt(size_t index) const noexcept;

[[nodiscard]] luisa::span<const MotionInstanceTransform> keyframes() const noexcept;
[[nodiscard]] luisa::span<const MotionInstanceTransformMatrix> keyframes_matrix() const noexcept;
[[nodiscard]] luisa::span<const MotionInstanceTransformSRT> keyframes_srt() const noexcept;

[[nodiscard]] auto keyframe_count() const noexcept { return _transform_keyframes.size(); }
[[nodiscard]] auto mode() const noexcept { return _mode; }

[[nodiscard]] luisa::unique_ptr<Command> build() noexcept;
};

}// namespace luisa::compute
//
// Created by Mike on 2024/9/21.
//

#pragma once

#include <luisa/runtime/device.h>

namespace luisa::compute {

class Curve;
class Mesh;
class ProceduralPrimitive;

class LC_RUNTIME_API MotionInstance : public Resource {

friend class Device;

private:
uint64_t _child_handle;
AccelMotionMode _mode;
luisa::vector<MotionInstanceTransform> _transform_keyframes;

private:
// for internal use only; does not have linkages
MotionInstance(DeviceInterface *device,
const Resource &resource,
const AccelMotionOption &option) noexcept;

private:
MotionInstance(DeviceInterface *device,
const Mesh &mesh,
const AccelMotionOption &option) noexcept;

MotionInstance(DeviceInterface *device,
const Curve &curve,
const AccelMotionOption &option) noexcept;

MotionInstance(DeviceInterface *device,
const ProceduralPrimitive &primitive,
const AccelMotionOption &option) noexcept;

public:
MotionInstance(MotionInstance &&) noexcept = default;
MotionInstance &operator=(MotionInstance &&rhs) noexcept {
_move_from(std::move(rhs));
return *this;
}
void set_keyframe(size_t index, const MotionInstanceTransform &transform) noexcept;
void set_keyframe(size_t index, const MotionInstanceTransformMatrix &transform) noexcept;
void set_keyframe(size_t index, const MotionInstanceTransformSRT &transform) noexcept;
void set_keyframes(luisa::span<const MotionInstanceTransform> transforms) noexcept;
void set_keyframes(luisa::span<const MotionInstanceTransformMatrix> transforms) noexcept;
void set_keyframes(luisa::span<const MotionInstanceTransformSRT> transforms) noexcept;

[[nodiscard]] const MotionInstanceTransform &keyframe(size_t index) const noexcept;
[[nodiscard]] const MotionInstanceTransformMatrix &keyframe_matrix(size_t index) const noexcept;
[[nodiscard]] const MotionInstanceTransformSRT &keyframe_srt(size_t index) const noexcept;

[[nodiscard]] luisa::span<const MotionInstanceTransform> keyframes() const noexcept;
[[nodiscard]] luisa::span<const MotionInstanceTransformMatrix> keyframes_matrix() const noexcept;
[[nodiscard]] luisa::span<const MotionInstanceTransformSRT> keyframes_srt() const noexcept;

[[nodiscard]] auto keyframe_count() const noexcept { return _transform_keyframes.size(); }
[[nodiscard]] auto mode() const noexcept { return _mode; }

[[nodiscard]] luisa::unique_ptr<Command> build() noexcept;
};

}// namespace luisa::compute

0 comments on commit 8c755dc

Please sign in to comment.