Ticket #3685: clearance.3.diff
File clearance.3.diff, 14.6 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/BuildRestrictions.js
133 133 if (!cmpObstruction) 134 134 return result; // Fail 135 135 136 var ret = cmpObstruction.CheckFoundation(passClassName); 136 137 137 if (this.template.Category == "Wall")138 {139 // for walls, only test the center point140 var ret = cmpObstruction.CheckFoundation(passClassName, true);141 }142 else143 {144 var ret = cmpObstruction.CheckFoundation(passClassName, false);145 }146 147 138 if (ret != "success") 148 139 { 149 140 switch (ret) -
binaries/data/mods/public/simulation/templates/other/bridge_hele.xml
20 20 </Identity> 21 21 <Minimap disable=""/> 22 22 <Obstruction> 23 <Static disable=""/> 23 24 <Obstructions> 24 25 <Edge width="59" depth="4" x="0" z="5"/> 25 26 </Obstructions> -
binaries/data/mods/public/simulation/templates/other/bridge_wooden.xml
19 19 <Icon>gaia/special_blank.png</Icon> 20 20 </Identity> 21 21 <Obstruction> 22 <Static disable=""/> 22 23 <Obstructions> 23 24 <Edge width="59" depth="4" x="0" z="5"/> 24 25 </Obstructions> -
binaries/data/mods/public/simulation/templates/other/palisades_rocks_tower.xml
30 30 <RequiredTechnology>phase_village</RequiredTechnology> 31 31 </Identity> 32 32 <Obstruction> 33 <Static width="4.0" depth="4.0" />33 <Static width="4.0" depth="4.0" clearance="-1"/> 34 34 <ControlPersist/> 35 35 </Obstruction> 36 36 <StatusBars> -
binaries/data/mods/public/simulation/templates/template_structure.xml
62 62 <Type>structure</Type> 63 63 </Minimap> 64 64 <Obstruction> 65 <Static width="2" depth="2" clearance="4"/> 65 66 <Active>true</Active> 66 67 <BlockMovement>true</BlockMovement> 67 68 <BlockPathfinding>true</BlockPathfinding> -
binaries/data/mods/public/simulation/templates/template_structure_defense_wall.xml
37 37 <metal>0</metal> 38 38 </Loot> 39 39 <Obstruction> 40 <Static width="6.0" depth="6.0" />40 <Static width="6.0" depth="6.0" clearance="0"/> 41 41 </Obstruction> 42 42 <RallyPoint disable=""/> 43 43 <Sound> -
binaries/data/mods/public/simulation/templates/template_structure_defense_wall_gate.xml
39 39 <metal>0</metal> 40 40 </Loot> 41 41 <Obstruction> 42 <Static disable=""/> 42 43 <Obstructions> 43 44 <Right width="5" depth="5" x="10" z="0"/> 44 45 <Left width="5" depth="5" x="-10" z="0"/> -
binaries/data/mods/public/simulation/templates/template_structure_defense_wall_tower.xml
64 64 <metal>0</metal> 65 65 </Loot> 66 66 <Obstruction> 67 <Static width="6.0" depth="6.0" />67 <Static width="6.0" depth="6.0" clearance="-1"/> 68 68 <ControlPersist/> 69 69 </Obstruction> 70 70 <ProductionQueue> -
source/simulation2/components/CCmpObstruction.cpp
122 122 "<param name='minInclusive'>1.5</param>" 123 123 "</data>" 124 124 "</attribute>" 125 "<optional>" 126 "<attribute name='clearance' a:help='Extra clearance to be applied when placing the entity, ensures there is passable space around it (can be negative to allow for overlap, if the overlap is small enough to not cause problems).'>" 127 "<data type='decimal'/>" 128 "</attribute>" 129 "</optional>" 125 130 "</element>" 126 131 "<element name='Unit'>" 127 132 "<empty/>" … … 216 221 m_Type = STATIC; 217 222 m_Size0 = paramNode.GetChild("Static").GetChild("@width").ToFixed(); 218 223 m_Size1 = paramNode.GetChild("Static").GetChild("@depth").ToFixed(); 224 m_Clearance = paramNode.GetChild("Static").GetChild("@clearance").ToFixed(); 219 225 ENSURE(m_Size0 > minObstruction); 220 226 ENSURE(m_Size1 > minObstruction); 221 227 } … … 244 250 } 245 251 m_Size0 = fixed::FromInt(2).Multiply(MAX(max.X, -min.X)); 246 252 m_Size1 = fixed::FromInt(2).Multiply(MAX(max.Y, -min.Y)); 253 // TODO perhaps support clearance per obstruction 254 m_Clearance = entity_pos_t::Zero(); 247 255 } 248 256 249 257 m_Active = paramNode.GetChild("Active").ToBool(); … … 525 533 526 534 virtual EFoundationCheck CheckFoundation(std::string className) 527 535 { 528 return CheckFoundation(className, false);529 }530 531 virtual EFoundationCheck CheckFoundation(std::string className, bool onlyCenterPoint)532 {533 536 CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); 534 537 if (!cmpPosition) 535 538 return FOUNDATION_CHECK_FAIL_ERROR; // error … … 560 563 ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); 561 564 562 565 if (m_Type == UNIT) 563 return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Clearance, passClass , onlyCenterPoint);566 return cmpPathfinder->CheckUnitPlacement(filter, pos.X, pos.Y, m_Clearance, passClass); 564 567 else 565 return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, onlyCenterPoint);568 return cmpPathfinder->CheckBuildingPlacement(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, GetEntityId(), passClass, m_Clearance * 2); 566 569 } 567 570 568 571 virtual bool CheckDuplicateFoundation() -
source/simulation2/components/CCmpPathfinder.cpp
801 801 } 802 802 803 803 ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckUnitPlacement(const IObstructionTestFilter& filter, 804 entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass , bool UNUSED(onlyCenterPoint))804 entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass) 805 805 { 806 806 // Check unit obstruction 807 807 CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); … … 829 829 entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, 830 830 entity_pos_t h, entity_id_t id, pass_class_t passClass) 831 831 { 832 return CCmpPathfinder::CheckBuildingPlacement(filter, x, z, a, w, h, id, passClass, false);832 return CCmpPathfinder::CheckBuildingPlacement(filter, x, z, a, w, h, id, passClass, entity_pos_t::Zero()); 833 833 } 834 834 835 835 836 836 ICmpObstruction::EFoundationCheck CCmpPathfinder::CheckBuildingPlacement(const IObstructionTestFilter& filter, 837 837 entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, 838 entity_pos_t h, entity_id_t id, pass_class_t passClass, bool UNUSED(onlyCenterPoint))838 entity_pos_t h, entity_id_t id, pass_class_t passClass, entity_pos_t clearance) 839 839 { 840 840 // Check unit obstruction 841 841 CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSystemEntity()); … … 842 842 if (!cmpObstructionManager) 843 843 return ICmpObstruction::FOUNDATION_CHECK_FAIL_ERROR; 844 844 845 if (cmpObstructionManager->TestStaticShape(filter, x, z, a, w , h, NULL))845 if (cmpObstructionManager->TestStaticShape(filter, x, z, a, w + clearance, h + clearance, NULL)) 846 846 return ICmpObstruction::FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION; 847 847 848 848 // Test against terrain: -
source/simulation2/components/CCmpPathfinder_Common.h
212 212 213 213 virtual bool CheckMovement(const IObstructionTestFilter& filter, entity_pos_t x0, entity_pos_t z0, entity_pos_t x1, entity_pos_t z1, entity_pos_t r, pass_class_t passClass); 214 214 215 virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass , bool onlyCenterPoint);215 virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass); 216 216 217 217 virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass); 218 218 219 virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint);219 virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, entity_pos_t clearance); 220 220 221 221 virtual void FinishAsyncRequests(); 222 222 -
source/simulation2/components/ICmpObstruction.cpp
23 23 24 24 #include "simulation2/system/SimContext.h" 25 25 26 std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& className , bool onlyCenterPoint)26 std::string ICmpObstruction::CheckFoundation_wrapper(const std::string& className) 27 27 { 28 EFoundationCheck check = CheckFoundation(className , onlyCenterPoint);28 EFoundationCheck check = CheckFoundation(className); 29 29 30 30 switch (check) 31 31 { … … 47 47 48 48 BEGIN_INTERFACE_WRAPPER(Obstruction) 49 49 DEFINE_INTERFACE_METHOD_0("GetUnitRadius", entity_pos_t, ICmpObstruction, GetUnitRadius) 50 DEFINE_INTERFACE_METHOD_ 2("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string, bool)50 DEFINE_INTERFACE_METHOD_1("CheckFoundation", std::string, ICmpObstruction, CheckFoundation_wrapper, std::string) 51 51 DEFINE_INTERFACE_METHOD_0("CheckDuplicateFoundation", bool, ICmpObstruction, CheckDuplicateFoundation) 52 52 DEFINE_INTERFACE_METHOD_0("GetUnitCollisions", std::vector<entity_id_t>, ICmpObstruction, GetUnitCollisions) 53 53 DEFINE_INTERFACE_METHOD_1("SetActive", void, ICmpObstruction, SetActive, bool) -
source/simulation2/components/ICmpObstruction.h
68 68 * value describing the type of failure. 69 69 */ 70 70 virtual EFoundationCheck CheckFoundation(std::string className) = 0; 71 virtual EFoundationCheck CheckFoundation(std::string className, bool onlyCenterPoint) = 0;72 71 73 72 /** 74 73 * CheckFoundation wrapper for script calls, to return friendly strings instead of an EFoundationCheck. 75 74 * @return "success" if check passes, else a string describing the type of failure. 76 75 */ 77 virtual std::string CheckFoundation_wrapper(const std::string& className , bool onlyCenterPoint);76 virtual std::string CheckFoundation_wrapper(const std::string& className); 78 77 79 78 /** 80 79 * Test whether this entity is colliding with any obstructions that share its -
source/simulation2/components/ICmpPathfinder.h
134 134 /** 135 135 * Check whether a unit placed here is valid and doesn't hit any obstructions 136 136 * or impassable terrain. 137 * When onlyCenterPoint = true, only check the center tile of the unit138 137 * @return ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else 139 138 * a value describing the type of failure. 140 139 */ 141 virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass , bool onlyCenterPoint = false) = 0;140 virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t r, pass_class_t passClass) = 0; 142 141 143 142 /** 144 143 * Check whether a building placed here is valid and doesn't hit any obstructions … … 151 150 /** 152 151 * Check whether a building placed here is valid and doesn't hit any obstructions 153 152 * or impassable terrain. 154 * when onlyCenterPoint = true, only check the center tile of the building155 153 * @return ICmpObstruction::FOUNDATION_CHECK_SUCCESS if the placement is okay, else 156 154 * a value describing the type of failure. 157 155 */ 158 virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, bool onlyCenterPoint) = 0;156 virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter& filter, entity_pos_t x, entity_pos_t z, entity_pos_t a, entity_pos_t w, entity_pos_t h, entity_id_t id, pass_class_t passClass, entity_pos_t clearance) = 0; 159 157 160 158 161 159 /**