void apply_scene_scale(TargetObject obj, Vector3f scale) { // construct scaled scene frame and update SO Frame3f f = obj.sceneFrame; f.Origin = scale * (f.Origin - sharedOriginS) + sharedOriginS; obj.curSceneFrame = f; obj.SO.SetLocalFrame(f, CoordSpace.SceneCoords); Frame3f fL = obj.SO.GetLocalFrame(CoordSpace.ObjectCoords); // transform is to map from original obj frame into scene, scale, and then map into scaled obj frame TransformSequence seq = new TransformSequence(); seq.AppendFromFrame(obj.objFrame); seq.AppendScale(scale, sharedOriginS); seq.AppendToFrame(fL); obj.SO.EditAndUpdateMesh((mesh) => { // restore original positions mesh.VerticesBuffer.copy(obj.InputMeshV); if (obj.InputMeshN != null && mesh.HasVertexNormals) { mesh.NormalsBuffer.copy(obj.InputMeshN); } // apply xform MeshTransforms.PerVertexTransform(mesh, seq); }, GeometryEditTypes.VertexDeformation); }