#5263: "Model Scaler" doesn't handle model duplication correctly
| 15 | |
| 16 | // #5263: "Model Scaler" doesn't handle model duplication correctly |
| 17 | TEST_F(RadiantTest, DuplicateScaledModel) |
| 18 | { |
| 19 | loadMap("duplicate_scaled_model.map"); |
| 20 | |
| 21 | const std::string funcStaticName("moss01"); |
| 22 | const Vector3 scale(3, 4, 2); |
| 23 | auto func_static = algorithm::getEntityByName(GlobalSceneGraph().root(), funcStaticName); |
| 24 | |
| 25 | // Apply the scale to the model beneath the entity |
| 26 | func_static->foreachNode([&](const scene::INodePtr& node) |
| 27 | { |
| 28 | ITransformablePtr transformable = scene::node_cast<ITransformable>(node); |
| 29 | |
| 30 | if (transformable) |
| 31 | { |
| 32 | transformable->setType(TRANSFORM_PRIMITIVE); |
| 33 | transformable->setScale(scale); |
| 34 | transformable->freezeTransform(); |
| 35 | } |
| 36 | |
| 37 | return true; |
| 38 | }); |
| 39 | |
| 40 | auto model = algorithm::findChildModel(func_static); |
| 41 | |
| 42 | ASSERT_TRUE(model->hasModifiedScale()); |
| 43 | ASSERT_TRUE(model->getModelScale() == scale); |
| 44 | |
| 45 | // Select the func_static and duplicate it |
| 46 | GlobalSelectionSystem().setSelectedAll(false); |
| 47 | Node_setSelected(func_static, true); |
| 48 | |
| 49 | registry::setValue("user/ui/offsetClonedObjects", 0); |
| 50 | GlobalCommandSystem().executeCommand("CloneSelection"); |
| 51 | |
| 52 | auto duplicate = GlobalSelectionSystem().ultimateSelected(); |
| 53 | |
| 54 | // This must be the duplicate |
| 55 | ASSERT_TRUE(Node_getEntity(duplicate)->getKeyValue("name") != funcStaticName); |
| 56 | |
| 57 | // The new model must have a modified scale too |
| 58 | auto duplicatedModel = algorithm::findChildModel(duplicate); |
| 59 | ASSERT_TRUE(duplicatedModel->hasModifiedScale()); |
| 60 | ASSERT_TRUE(duplicatedModel->getModelScale() == scale); |
| 61 | } |
| 62 | |
| 63 | } |
nothing calls this directly
no test coverage detected