MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / GetRotationBasis

Function GetRotationBasis

Source/Editors/map_editor.cpp:3055–3070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3053}
3054
3055static bool GetRotationBasis(vec3 clicked_point, vec3 clicked_normal,
3056 Basis* basis, vec3* p, vec3* around,
3057 const Object* object_, const Box& box_) {
3058 const mat4& obj_transform = object_->GetTransform();
3059 const quaternion& obj_rot = object_->GetRotation();
3060 int i = box_.GetHitFaceIndex(invert(obj_rot) * clicked_normal, invert(obj_transform) * clicked_point);
3061 if (i == -1) {
3062 return false;
3063 }
3064 basis->up = obj_rot * Box::GetPlaneTangent(i);
3065 basis->facing = obj_rot * Box::GetPlaneNormal(i);
3066 basis->right = obj_rot * Box::GetPlaneBitangent(i);
3067 *around = Box::GetPlaneNormal(i);
3068 *p = obj_transform * box_.GetPlanePoint(i);
3069 return true;
3070}
3071
3072static vec3 GetTranslation(const LineSegment& mouseray, bool snapping_enabled, const vec3& cam_moved, const ControlEditorInfo* control_editor_info, Tool* tool_, Object* object_) {
3073 static const float TRANSLATION_SNAP_INCR = 0.50f; // percent of dimension in direction of movement

Callers 1

StartMouseTransformationFunction · 0.85

Calls 5

GetRotationMethod · 0.80
GetHitFaceIndexMethod · 0.80
GetPlanePointMethod · 0.80
invertFunction · 0.50
GetTransformMethod · 0.45

Tested by

no test coverage detected