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

Function GetTranslationBasis

Source/Editors/map_editor.cpp:3008–3032  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3006}
3007
3008static bool GetTranslationBasis(vec3 clicked_point, vec3 clicked_normal,
3009 Basis* basis, const Object* object_, const Box& box_, ToolMode tool_mode) {
3010 const mat4& obj_transform = object_->GetTransform();
3011 const quaternion& obj_rot = object_->GetRotation();
3012 int box_face_index = box_.GetHitFaceIndex(invert(obj_rot) * clicked_normal,
3013 invert(obj_transform) * clicked_point);
3014 if (box_face_index != -1) {
3015 switch (tool_mode) {
3016 case TRANSLATE_FACE_PLANE:
3017 basis->up = obj_rot * Box::GetPlaneTangent(box_face_index);
3018 basis->facing = obj_rot * Box::GetPlaneNormal(box_face_index);
3019 break;
3020 case TRANSLATE_FACE_NORMAL:
3021 basis->up = obj_rot * Box::GetPlaneTangent(box_face_index);
3022 basis->facing = obj_rot * Box::GetPlaneNormal(box_face_index);
3023 break;
3024 default:
3025 return false; // Tool is incorrect
3026 }
3027 basis->right = obj_rot * Box::GetPlaneBitangent(box_face_index);
3028 return true;
3029 } else {
3030 return false; // Didn't hit any box faces
3031 }
3032}
3033
3034// Returns false if no basis selected
3035static bool GetScaleBasis(vec3 clicked_point, vec3 clicked_normal,

Callers 1

StartMouseTransformationFunction · 0.85

Calls 4

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

Tested by

no test coverage detected