MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / TEST_F

Function TEST_F

test/ModelScale.cpp:17–61  ·  view source on GitHub ↗

#5263: "Model Scaler" doesn't handle model duplication correctly

Source from the content-addressed store, hash-verified

15
16// #5263: "Model Scaler" doesn't handle model duplication correctly
17TEST_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}

Callers

nothing calls this directly

Calls 15

getEntityByNameFunction · 0.85
findChildModelFunction · 0.85
Node_setSelectedFunction · 0.85
setValueFunction · 0.85
Node_getEntityFunction · 0.85
rootMethod · 0.45
foreachNodeMethod · 0.45
setTypeMethod · 0.45
setScaleMethod · 0.45
freezeTransformMethod · 0.45
hasModifiedScaleMethod · 0.45
getModelScaleMethod · 0.45

Tested by

no test coverage detected