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

Function GetScaleBasis

Source/Editors/map_editor.cpp:3035–3053  ·  view source on GitHub ↗

Returns false if no basis selected

Source from the content-addressed store, hash-verified

3033
3034// Returns false if no basis selected
3035static bool GetScaleBasis(vec3 clicked_point, vec3 clicked_normal,
3036 Basis* basis, vec3* p, const Object* object_, const Box& box_, ToolMode tool_mode) {
3037 const mat4& obj_transform = object_->GetTransform();
3038 const quaternion& obj_rot = object_->GetRotation();
3039
3040 int i = box_.GetHitFaceIndex(invert(obj_rot) * clicked_normal, invert(obj_transform) * clicked_point);
3041 if (i == -1) {
3042 return false;
3043 }
3044 basis->up = obj_rot * Box::GetPlaneTangent(i);
3045 basis->facing = obj_rot * Box::GetPlaneNormal(i);
3046 basis->right = obj_rot * Box::GetPlaneBitangent(i);
3047 if (tool_mode == SCALE_NORMAL) {
3048 *p = clicked_point;
3049 } else {
3050 *p = obj_transform * box_.GetPlanePoint(i);
3051 }
3052 return true;
3053}
3054
3055static bool GetRotationBasis(vec3 clicked_point, vec3 clicked_normal,
3056 Basis* basis, vec3* p, vec3* around,

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