mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-12 01:22:41 +02:00
allow drawing DebugDraw spheres with a specific size
This commit is contained in:
parent
64e4ff88e6
commit
73e6be9c37
3 changed files with 20 additions and 12 deletions
|
@ -393,7 +393,7 @@ void AnimDebugDraw::update() {
|
|||
glm::quat rot = std::get<0>(iter.second);
|
||||
glm::vec3 pos = std::get<1>(iter.second);
|
||||
glm::vec4 color = std::get<2>(iter.second);
|
||||
const float radius = POSE_RADIUS;
|
||||
const float radius = std::get<3>(iter.second) * POSE_RADIUS;
|
||||
addBone(AnimPose::identity, AnimPose(glm::vec3(1), rot, pos), radius, color, v);
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ void AnimDebugDraw::update() {
|
|||
glm::quat rot = std::get<0>(iter.second);
|
||||
glm::vec3 pos = std::get<1>(iter.second);
|
||||
glm::vec4 color = std::get<2>(iter.second);
|
||||
const float radius = POSE_RADIUS;
|
||||
const float radius = std::get<3>(iter.second) * POSE_RADIUS;
|
||||
addBone(myAvatarPose, AnimPose(glm::vec3(1), rot, pos), radius, color, v);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,10 @@ void DebugDraw::drawRay(const glm::vec3& start, const glm::vec3& end, const glm:
|
|||
_rays.push_back(Ray(start, end, color));
|
||||
}
|
||||
|
||||
void DebugDraw::addMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position, const glm::vec4& color) {
|
||||
void DebugDraw::addMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position,
|
||||
const glm::vec4& color, float size) {
|
||||
Lock lock(_mapMutex);
|
||||
_markers[key] = MarkerInfo(rotation, position, color);
|
||||
_markers[key] = MarkerInfo(rotation, position, color, size);
|
||||
}
|
||||
|
||||
void DebugDraw::removeMarker(const QString& key) {
|
||||
|
@ -41,9 +42,10 @@ void DebugDraw::removeMarker(const QString& key) {
|
|||
_markers.erase(key);
|
||||
}
|
||||
|
||||
void DebugDraw::addMyAvatarMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position, const glm::vec4& color) {
|
||||
void DebugDraw::addMyAvatarMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position,
|
||||
const glm::vec4& color, float size) {
|
||||
Lock lock(_mapMutex);
|
||||
_myAvatarMarkers[key] = MarkerInfo(rotation, position, color);
|
||||
_myAvatarMarkers[key] = MarkerInfo(rotation, position, color, size);
|
||||
}
|
||||
|
||||
void DebugDraw::removeMyAvatarMarker(const QString& key) {
|
||||
|
@ -83,4 +85,4 @@ void DebugDraw::drawRays(const std::vector<std::pair<glm::vec3, glm::vec3>>& lin
|
|||
auto point2 = translation + rotation * line.second;
|
||||
_rays.push_back(Ray(point1, point2, color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,19 +95,22 @@ public:
|
|||
* @param {Quat} rotation - The orientation of the marker in world coordinates.
|
||||
* @param {Vec3} position - The position of the market in world coordinates.
|
||||
* @param {Vec4} color - The color of the marker.
|
||||
* @param {float} size - A float between 0.0 and 1.0 (10 cm) to control the size of the marker.
|
||||
* @example <caption>Briefly draw a debug marker in front of your avatar, in world coordinates.</caption>
|
||||
* var MARKER_NAME = "my marker";
|
||||
* DebugDraw.addMarker(
|
||||
* MARKER_NAME,
|
||||
* Quat.ZERO,
|
||||
* Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -5})),
|
||||
* { red: 255, green: 0, blue: 0 }
|
||||
* { red: 255, green: 0, blue: 0 },
|
||||
* 1.0
|
||||
* );
|
||||
* Script.setTimeout(function () {
|
||||
* DebugDraw.removeMarker(MARKER_NAME);
|
||||
* }, 5000);
|
||||
*/
|
||||
Q_INVOKABLE void addMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position, const glm::vec4& color);
|
||||
Q_INVOKABLE void addMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position,
|
||||
const glm::vec4& color, float size = 1.0f);
|
||||
|
||||
/**jsdoc
|
||||
* Removes a debug marker that was added in world coordinates.
|
||||
|
@ -125,19 +128,22 @@ public:
|
|||
* @param {Quat} rotation - The orientation of the marker in avatar coordinates.
|
||||
* @param {Vec3} position - The position of the market in avatar coordinates.
|
||||
* @param {Vec4} color - color of the marker.
|
||||
* @param {float} size - A float between 0.0 and 1.0 (10 cm) to control the size of the marker.
|
||||
* @example <caption>Briefly draw a debug marker in front of your avatar, in avatar coordinates.</caption>
|
||||
* var MARKER_NAME = "My avatar marker";
|
||||
* DebugDraw.addMyAvatarMarker(
|
||||
* MARKER_NAME,
|
||||
* Quat.ZERO,
|
||||
* { x: 0, y: 0, z: -5 },
|
||||
* { red: 255, green: 0, blue: 0 }
|
||||
* { red: 255, green: 0, blue: 0 },
|
||||
* 1.0
|
||||
* );
|
||||
* Script.setTimeout(function () {
|
||||
* DebugDraw.removeMyAvatarMarker(MARKER_NAME);
|
||||
* }, 5000);
|
||||
*/
|
||||
Q_INVOKABLE void addMyAvatarMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position, const glm::vec4& color);
|
||||
Q_INVOKABLE void addMyAvatarMarker(const QString& key, const glm::quat& rotation, const glm::vec3& position,
|
||||
const glm::vec4& color, float size = 1.0f);
|
||||
|
||||
/**jsdoc
|
||||
* Removes a debug marker that was added in avatar coordinates.
|
||||
|
@ -146,7 +152,7 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE void removeMyAvatarMarker(const QString& key);
|
||||
|
||||
using MarkerInfo = std::tuple<glm::quat, glm::vec3, glm::vec4>;
|
||||
using MarkerInfo = std::tuple<glm::quat, glm::vec3, glm::vec4, float>;
|
||||
using MarkerMap = std::map<QString, MarkerInfo>;
|
||||
using Ray = std::tuple<glm::vec3, glm::vec3, glm::vec4>;
|
||||
using Rays = std::vector<Ray>;
|
||||
|
|
Loading…
Reference in a new issue