MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ follow_attachment()

MAYAFLUX_API void MayaFlux::Nexus::follow_attachment ( Attachment &  attachment,
std::optional< glm::vec3 > &  position,
const std::optional< glm::quat > &  orientation 
)

Set position from the buffer, or fold an outside move into the attachment.

Parameters
attachmentAttachment to follow.
positionPosition of the Agent. Set if empty.
orientationOrientation of the Agent, if it has one.

Definition at line 107 of file Attachment.cpp.

111{
112 const glm::quat rotation = frame(orientation);
113 glm::vec3 placed = glm::vec3(*attachment.transform * glm::vec4(attachment.anchor, 1.0F));
114
115 if (position && *position != attachment.applied) {
116 const glm::vec3 delta = *position - attachment.applied;
117 if (attachment.config.on_move == AttachConfig::OnMove::Carry) {
118 *attachment.transform = glm::translate(glm::mat4(1.0F), delta) * *attachment.transform;
119 placed += delta;
120 } else {
121 attachment.config.offset += glm::inverse(rotation) * delta;
122 }
123 }
124
125 position = placed + rotation * attachment.config.offset;
126 attachment.applied = *position;
127}
std::optional< glm::vec3 > position
Definition Decoder.cpp:93
glm::vec3 offset
Offset of the Agent from the anchor, in the Agent's own frame.
std::shared_ptr< glm::mat4 > transform

References MayaFlux::Nexus::Attachment::anchor, MayaFlux::Nexus::Attachment::applied, MayaFlux::Nexus::AttachConfig::Carry, MayaFlux::Nexus::Attachment::config, MayaFlux::Nexus::AttachConfig::offset, MayaFlux::Nexus::AttachConfig::on_move, position, and MayaFlux::Nexus::Attachment::transform.

Referenced by MayaFlux::Nexus::Agent::follow_attachment(), and MayaFlux::Nexus::Emitter::follow_attachment().

+ Here is the caller graph for this function: