def _get_constraint(self, sim): if self._focus is None: logger.error( 'Attempt to get a constraint for a Sim before the group constraint is initialized: {} for {}', self, sim, owner='camilogarcia') return Anywhere() geometric_constraint = self._constraint if geometric_constraint is None: logger.error( 'Attempt to get the constraint from a Social group before it has been initialized. Social Group is {}, Size of group is {}, and minimum number allowed for group is {}', self, len(self), self.minimum_sim_count, owner='camilogarcia') return Anywhere() scoring_constraints = [] for other_sim in self: if other_sim is sim: continue facing_anchor = self._anchor_object if self._anchor_object is not None else other_sim force_readjustment = sim.id in self._pending_adjustments if force_readjustment: self._pending_adjustments.remove(sim.id) scoring_constraint = self.facing_restriction.create_constraint( sim, facing_anchor, scoring_functions=(self.scoring_function( sim, other_sim, force_readjustment), )) scoring_constraints.append(scoring_constraint) scoring_constraints = create_constraint_set(scoring_constraints) geometric_constraint = geometric_constraint.intersect( scoring_constraints) return geometric_constraint
def make_constraint_default(cls, actor, target_sim, position, routing_surface, participant_type=ParticipantType.Actor, picked_object=None, participant_slot_overrides=None): (actor_transform, target_transform, routing_surface) = cls._get_jig_transforms( actor, target_sim, picked_object=picked_object, participant_slot_overrides=participant_slot_overrides) if actor_transform is None or target_transform is None: return Nowhere() if participant_type == ParticipantType.Actor: constraint_transform = actor_transform elif participant_type == ParticipantType.TargetSim: constraint_transform = target_transform else: return Anywhere() return interactions.constraints.Transform( constraint_transform, routing_surface=routing_surface, debug_name='JigGroupConstraint')
def prepare_gen(self, timeline, *args, **kwargs): result = yield super().prepare_gen(timeline, *args, **kwargs) if result != InteractionQueuePreparationStatus.SUCCESS: return result constraint_target = self.get_participant( participant_type=self.clear_constraints_actor) sim = self.get_participant(ParticipantType.Actor, target=constraint_target) if sim is None: return result if constraint_target is None: return result intersection = Anywhere() for tuned_constraint in self.clear_constraints: constraint = tuned_constraint.create_constraint( sim, constraint_target) constraint = constraint.create_concrete_version(self) intersection = constraint.intersect(intersection) while not intersection.valid: return result for constraint_polygon in constraint.polygons: if isinstance(constraint_polygon, sims4.geometry.CompoundPolygon): for polygon in constraint_polygon: UserFootprintHelper.force_move_sims_in_polygon( polygon, constraint_target.routing_surface, exclude=[sim]) else: UserFootprintHelper.force_move_sims_in_polygon( constraint_polygon, constraint_target.routing_surface, exclude=[sim]) return result
def make_constraint_default(cls, actor, target_sim, position, routing_surface, participant_type=ParticipantType.Actor, picked_object=None, participant_slot_overrides=None): if participant_type not in (ParticipantType.Actor, ParticipantType.TargetSim): return Anywhere() all_transforms = [] for (actor_transform, target_transform, routing_surface, _) in cls._get_jig_transforms_gen( actor, target_sim, picked_object=picked_object, participant_slot_overrides=participant_slot_overrides): if participant_type == ParticipantType.Actor: transform = actor_transform else: transform = target_transform if transform is None: continue all_transforms.append( interactions.constraints.Transform( transform, routing_surface=routing_surface, debug_name='JigGroupConstraint')) if not all_transforms: return Nowhere('Unable to get constraints from jig.') return create_constraint_set(all_transforms)
def get_total_constraint(sim): if sim.queue.running is not None and sim.queue.running.is_super and sim.queue.running.transition is not None: constraint = sim.queue.running.transition.get_final_constraint(sim) else: constraint = Anywhere() total_constraint = sim.si_state.get_total_constraint( include_inertial_sis=True, existing_constraint=constraint) return total_constraint
def get_constraint(self, sim): transform = self._sim_transform_map.get(sim, None) if transform is not None: return interactions.constraints.Transform( transform, routing_surface=self.routing_surface) if sim in self._sim_transform_map: return Nowhere() return Anywhere()
def _make_constraint(self, *args, **kwargs): all_constraints = [ self.get_constraint(sim) for sim in self._sim_transform_map ] if all_constraints: self._constraint = create_constraint_set(all_constraints) else: self._constraint = Anywhere() return self._constraint
def get_pick_up_constraint(self, sim): if self.constraint_pick_up is None: return final_constraint = Anywhere() for constraint in self.constraint_pick_up: constraint = self._get_adjusted_circle_constraint(sim, constraint) constraint = constraint.create_constraint(sim, target=self.owner) final_constraint = final_constraint.intersect(constraint) final_constraint = final_constraint._copy(_multi_surface=True) return final_constraint
def _make_constraint(self, *args, **kwargs): if self._constraint is None: constraints = [ interactions.constraints.Transform( t, routing_surface=self.routing_surface) for t in self._sim_transform_map.values() ] self._constraint = create_constraint_set( constraints) if constraints else Anywhere() return self._constraint
def get_constraint(self): if self._constraint is None or not self._constraint.valid: self._constraint = Anywhere() for tuned_constraint in self.constraints: self._constraint = self._constraint.intersect( tuned_constraint.create_constraint( None, target=self.broadcasting_object, target_position=self.broadcasting_object.position)) return self._constraint
def _do_behavior(self): self._reaction_constraint = Anywhere() for tuned_reaction_constraint in self.reaction_constraints: self._reaction_constraint = self._reaction_constraint.intersect( tuned_reaction_constraint.create_constraint( None, target=self._reaction_target_sim)) if self.trigger_on_late_arrivals: self._reaction_target_sim.reaction_triggers[ self.interaction] = self for sim in services.sim_info_manager().instanced_sims_gen(): self.intersect_and_execute(sim)
def _constraint_gen(cls, inst, sim, target, *args, **kwargs): travel_group = sim.sim_info.travel_group if len(travel_group) == 1: yield Anywhere() else: yield from super()._constraint_gen( sim, target, *args, to_zone_id=sim.sim_info.household.home_zone_id, **kwargs)
def constraint_intersection(cls, inst, sim=DEFAULT, participant_type=ParticipantType.Actor, **kwargs): if inst is None or participant_type != ParticipantType.Actor: return Anywhere() if inst._constraint_to_satisfy is not DEFAULT: return inst._constraint_to_satisfy if sim is DEFAULT: sim = inst.get_participant(participant_type) return sim.si_state.get_total_constraint(to_exclude=inst)
def get_constraint(self, sim, **kwargs): carryable = self._obj.get_component(CARRYABLE_COMPONENT) if carryable is not None and carryable.constraint_pick_up is not None: constraint_total = Anywhere() for constraint_factory in carryable.constraint_pick_up: constraint = constraint_factory.create_constraint( sim, target=self._obj, routing_surface=self._obj.routing_surface) constraint_total = constraint_total.intersect(constraint) return constraint_total return super().get_constraint(sim)
def constraint_intersection(self): if self._constraint_intersection_dirty: intersection = Anywhere() for constraint in set(self._constraints.values()): new_intersection = intersection.intersect(constraint) if not self._invalid_expected and not new_intersection.valid: logger.error('Invalid constraint intersection for PostureState:{}', self) intersection = new_intersection break intersection = new_intersection self._constraint_intersection_dirty = False self._constraint_intersection = intersection return self._constraint_intersection
def _find_target(self): all_objects = self.target_type.get_objects() objects = [] for o in all_objects: dist_sq = (o.position - self._obj.position).magnitude_squared() if dist_sq > self.radius: continue if o == self: continue if not o.is_sim and not o.may_reserve(self._obj): continue if self.target_selection_test: resolver = DoubleObjectResolver(self._obj, o) if not self.target_selection_test.run_tests(resolver): continue else: objects.append([o, dist_sq]) if not objects: return source_handles = [ routing.connectivity.Handle(self._obj.position, self._obj.routing_surface) ] dest_handles = [] for o in objects: obj = o[0] parent = obj.parent route_to_obj = parent if parent is not None else obj constraint = Anywhere() for tuned_constraint in self.constraints: constraint = constraint.intersect( tuned_constraint.create_constraint(self._obj, route_to_obj)) dests = constraint.get_connectivity_handles(self._obj, target=obj) if dests: dest_handles.extend(dests) if not dest_handles: return routing_context = self._obj.get_routing_context() connections = routing.estimate_path_batch( source_handles, dest_handles, routing_context=routing_context) if not connections: return connections.sort(key=lambda connection: connection[2]) best_connection = connections[0] best_dest_handle = best_connection[1] best_obj = best_dest_handle.target return best_obj
def get_constraint(self, participant_type=ParticipantType.Actor): from interactions.constraints import Anywhere, create_animation_constraint if participant_type == ParticipantType.Actor: actor_name = self.actor_name target_name = self.target_name elif participant_type == ParticipantType.TargetSim: actor_name = self.target_name target_name = self.actor_name else: return Anywhere() return create_animation_constraint(self.asm_key, actor_name, target_name, self.carry_target_name, self.create_target_name, self.initial_state, self.begin_states, self.end_states, self.overrides)
def get_constraint(self, sim): transforms = self._sim_transform_map.get(sim, None) if transforms is not None: all_transforms = [ interactions.constraints.Transform( transform, routing_surface=self.routing_surface, create_jig_fn=self._set_sim_intended_location) for (transform, _) in transforms ] return create_constraint_set(all_transforms) if sim in self._sim_transform_map: return Nowhere( "JigGroup, Sim is expected to have a transform but we didn't find a good spot for them. Sim: {}", sim) return Anywhere()
def _build_constraint(self, context): all_objects = list(services.object_manager().values()) random.shuffle(all_objects) for obj in all_objects: if not obj.is_sim: if not obj.is_on_active_lot(): continue resolver = SingleObjectResolver(obj) if not self.object_tests.run_tests(resolver): continue constraint = self.circle_constraint_around_chosen_object.create_constraint( context.sim, obj) if constraint.valid: return constraint logger.warn( 'No objects were found for this interaction to route the Sim near. Interaction = {}', type(self)) return Anywhere()
def get_routes_gen(self): if self._target is None: self.on_no_target() return False yield routing_slot_constraint = Anywhere() for tuned_constraint in self.constraints: routing_slot_constraint = routing_slot_constraint.intersect( tuned_constraint.create_constraint(self._obj, self._target)) goals = list( itertools.chain.from_iterable( h.get_goals() for h in routing_slot_constraint.get_connectivity_handles( self._obj))) routing_context = self._obj.get_routing_context() route = routing.Route(self._obj.routing_location, goals, routing_context=routing_context) yield route
def _on_posture_event(self, change, dest_state, track, source_posture, dest_posture): if not PostureTrack.is_body(track): return sim = dest_state.sim if change == PostureEvent.TRANSITION_START: if sim.queue.running is not None and sim.queue.running.is_super: constraint = sim.queue.running.transition.get_final_constraint( sim) else: constraint = Anywhere() elif change in DONE_POSTURE_EVENTS: constraint = sim.si_state.get_total_constraint( include_inertial_sis=True) self._dest_state = dest_state else: return self._register_on_constraint_changed_for_groups() if dest_state is not None: self._on_rebuild(sim, constraint)
def constraint_intersection(self): if self._constraint_intersection_dirty or self._constraint_intersection is None: intersection = Anywhere() for constraint in set(self._constraints.values()): new_intersection = intersection.intersect(constraint) if not self._invalid_expected: if not new_intersection.valid: indent_text = ' ' logger.error( 'Invalid constraint intersection for PostureState: {}.\n A: {} \n A Geometry: {} B: {} \n B Geometry: {}', self, intersection, intersection.get_geometry_text(indent_text), constraint, constraint.get_geometry_text(indent_text)) intersection = new_intersection break intersection = new_intersection self._constraint_intersection_dirty = False self._constraint_intersection = intersection return self._constraint_intersection
def get_carry_transition_constraint(self, sim, position, routing_surface, cost=0, mobile=True): constraints = self.DEFAULT_GEOMETRIC_TRANSITION_CONSTRAINT constraints = constraints.constraint_mobile if mobile else constraints.constraint_non_mobile final_constraint = Anywhere() for constraint in constraints: if mobile: constraint = self._get_adjusted_circle_constraint( sim, constraint) final_constraint = final_constraint.intersect( constraint.create_constraint(None, None, target_position=position, routing_surface=routing_surface)) final_constraint = final_constraint.generate_constraint_with_cost(cost) final_constraint = final_constraint._copy(_multi_surface=True) return final_constraint
def __call__(self, constraint_targets=(), test_actors=()): test_actor = test_actors[0] if test_actors else None sim_info_manager = services.sim_info_manager() instanced_sims = list(sim_info_manager.instanced_sims_gen()) for target in constraint_targets: if target.is_sim: target = target.get_sim_instance() if target is None: continue else: total_constraint = Anywhere() for tuned_constraint in self.constraints: total_constraint = total_constraint.intersect(tuned_constraint.create_constraint(None, target)) if not total_constraint.valid: return TestResult(False, 'Constraint {} relative to {} is invalid.', tuned_constraint, target, tooltip=self.tooltip) object_constraint = interactions.constraints.Position(target._get_locations_for_posture_internal_forward_wall_padding(), routing_surface=target.routing_surface) for sim in instanced_sims: if not (total_constraint.geometry.test_transform(sim.transform) and (total_constraint.is_routing_surface_valid(sim.routing_surface) and (total_constraint.is_location_water_depth_valid(sim.location) and (total_constraint.is_location_terrain_tags_valid(sim.location) and not self.test_set(DoubleSimResolver(test_actor, sim.sim_info))))) and not (self.must_be_line_of_sight and sim.sim_info is test_actor)): if not object_constraint.intersect(sim.lineofsight_component.constraint).valid: continue return TestResult(False, 'Sims In Constraint Test Failed.', tooltip=self.tooltip) return TestResult.TRUE
class GetPutComponentMixin(HasTunableFactory, metaclass=ComponentMetaclass): __qualname__ = 'GetPutComponentMixin' GENERIC_GET_ANIMATION = TunableAnimationReference() GENERIC_PUT_ANIMATION = TunableAnimationReference() GENERIC_CONSTRAINT = Anywhere() @classmethod def register_tuned_animation(cls, *_, **__): pass @classmethod def add_auto_constraint(cls, participant_type, tuned_constraint, **kwargs): cls.GENERIC_CONSTRAINT = cls.GENERIC_CONSTRAINT.intersect( tuned_constraint) FACTORY_TUNABLES = { 'get_put': TunableVariant( description= '\n This controls the behavior of a Sim who wants to get from or\n put to the component owner.\n ', default='none', locked_args={'none': None}, generic=GenericAnimation.TunableFactory(), custom=CustomAnimation.TunableFactory()) } def __init__(self, *args, get_put=None, **kwargs): super().__init__(*args, **kwargs) self._get_put = get_put def _get_access_constraint(self, sim, is_put, carry_target, resolver=None): if self._get_put is None: return constraint = self._get_put.get_access_constraint(is_put, self.owner) def constraint_resolver(animation_participant, default=None): if resolver is not None: result = resolver(animation_participant, default=default) if result is not default: return result if animation_participant == AnimationParticipant.ACTOR: return sim if animation_participant in (AnimationParticipant.CARRY_TARGET, AnimationParticipant.TARGET): return carry_target if animation_participant == AnimationParticipant.SURFACE: return self.owner return default concrete_constraint = constraint.apply_posture_state( None, constraint_resolver) return concrete_constraint def get_surface_target(self, sim): inv_owner = self.owner body_target = sim.posture.target if body_target is not None and body_target.inventory_component is not None and body_target.inventory_component.inventory_type == inv_owner.inventory_component.inventory_type: return body_target return inv_owner def _get_access_animation(self, is_put): if self._get_put is None: return animation_factory = self._get_put.get_access_animation_factory(is_put) if animation_factory is None: return def append_animations(arb, sim, carry_target, carry_track, animation_context, surface_height): asm = sim.posture.get_asm(animation_context, animation_factory.asm_key, None, use_cache=False) asm.set_parameter('surfaceHeight', surface_height) sim.posture.setup_asm_interaction( asm, sim, None, animation_factory.actor_name, None, carry_target=carry_target, carry_target_name=animation_factory.carry_target_name, surface_target=self.get_surface_target(sim), carry_track=carry_track) asm.set_actor_parameter(animation_factory.carry_target_name, carry_target, PARAM_CARRY_TRACK, carry_track.name.lower()) animation_factory.append_to_arb(asm, arb) animation_factory.append_exit_to_arb(asm, arb) return append_animations
def _draw_constraint(layer, constraint, color, altitude_modifier=0, anywhere_position=None): if constraint is None: return if isinstance(constraint, RequiredSlotSingle): constraint = constraint._intersect(Anywhere()) if constraint.IS_CONSTRAINT_SET: drawn_geometry = [] for sub_constraint in constraint._constraints: if sub_constraint._geometry is not None: if sub_constraint._geometry in drawn_geometry: _draw_constraint( layer, sub_constraint.generate_alternate_geometry_constraint( None), color, altitude_modifier) drawn_geometry.append(sub_constraint._geometry) _draw_constraint(layer, sub_constraint, color, altitude_modifier) altitude_modifier += 0.1 return (r, g, b, a) = sims4.color.to_rgba(color) semitransparent = sims4.color.from_rgba(r, g, b, a * 0.5) transparent = sims4.color.from_rgba(r, g, b, a * 0.25) layer.routing_surface = constraint.routing_surface if constraint.geometry is not None: if constraint.geometry.polygon is not None: drawn_facings = [] drawn_points = [] drawn_polys = [] for poly in constraint.geometry.polygon: poly_key = list(poly) if poly_key not in drawn_polys: drawn_polys.append(poly_key) layer.add_polygon(poly, color=color, altitude=altitude_modifier + 0.1) def draw_facing(point, color): altitude = altitude_modifier + 0.1 (valid, interval ) = constraint._geometry.get_orientation_range(point) if valid and interval is not None: if interval.a != interval.b: if interval.angle >= sims4.math.TWO_PI: angles = [(interval.ideal, True)] else: angles = [(interval.a, False), (interval.ideal, True), (interval.b, False)] else: angles = [(interval.a, True)] for (angle, arrowhead) in angles: facings_key = (point, angle, arrowhead) while facings_key not in drawn_facings: drawn_facings.append(facings_key) layer.add_arrow(point, angle, end_arrow=arrowhead, length=0.2, color=color, altitude=altitude) else: point_key = point if point_key not in drawn_points: drawn_points.append(point_key) layer.add_point(point, color=color, altitude=altitude) if not constraint.geometry.restrictions: pass for vertex in poly: draw_facing(vertex, color) for i in range(len(poly)): v1 = poly[i] v2 = poly[(i + 1) % len(poly)] draw_facing(v1, transparent) draw_facing(0.5 * (v1 + v2), transparent) if _number_of_random_weight_points: num_random_points = _number_of_random_weight_points else: num_random_points = math.ceil(poly.area() * RANDOM_WEIGHT_DENSITY) while num_random_points: while True: for point in random_uniform_points_in_polygon( poly, num_random_points): orientation = sims4.math.Quaternion.IDENTITY() if constraint._geometry is not None: (valid, quat) = constraint._geometry.get_orientation( point) if quat is not None: orientation = quat draw_facing(point, transparent) score = constraint.get_score(point, orientation) color = red_green_lerp(score, a * 0.33) layer.add_point(point, size=0.025, color=color) elif constraint.geometry.restrictions: for restriction in constraint.geometry.restrictions: if isinstance(restriction, RelativeFacingRange): layer.add_point(restriction.target, color=color) else: while isinstance(restriction, RelativeFacingWithCircle): layer.add_circle(restriction.target, radius=restriction.radius, color=color) if isinstance(constraint, RequiredSlotSingle): while True: for (routing_transform, _) in itertools.chain( constraint._slots_to_params_entry or (), constraint._slots_to_params_exit or ()): layer.add_arrow_for_transform(routing_transform, length=0.1, color=semitransparent, altitude=altitude_modifier) layer.add_segment( routing_transform.translation, constraint.containment_transform.translation, color=transparent, altitude=altitude_modifier) elif isinstance(constraint, Anywhere) and anywhere_position is not None: layer.add_circle(anywhere_position, radius=0.28, color=transparent, altitude=altitude_modifier) layer.add_circle(anywhere_position, radius=0.3, color=semitransparent, altitude=altitude_modifier)
def get_combined_constraint(self, existing_constraint=None, priority=None, group_id=None, to_exclude=None, include_inertial_sis=False, force_inertial_sis=False, existing_si=None, posture_state=DEFAULT, allow_posture_providers=True, include_existing_constraint=True, participant_type=ParticipantType.Actor): included_sis = set() if include_inertial_sis: if existing_si is not None and any(si.id == existing_si.continuation_id for si in self): sis_must_include = set() else: sis_must_include = self._get_must_include_sis(priority, group_id, existing_si=existing_si) if force_inertial_sis: for si in self._super_interactions: if si in sis_must_include: continue if not allow_posture_providers and self.sim.posture_state.is_source_interaction(si): continue if not self._common_included_si_tests(si): continue sis_must_include.add(si) to_consider = set() is_like_vehicle = self.sim.posture.is_vehicle or self.sim.parent_may_move for non_guaranteed_si in self._super_interactions: if non_guaranteed_si in sis_must_include: continue if not is_like_vehicle: continue if not allow_posture_providers and (self.sim.posture_state.is_source_interaction(non_guaranteed_si) and self.sim.posture.is_vehicle) and existing_constraint is not None: final_surfaces = {constraint.routing_surface.type for constraint in existing_constraint if constraint.routing_surface is not None} vehicle = self.sim.posture.target vehicle_surfaces = vehicle.vehicle_component.allowed_surfaces if final_surfaces and not any(final_surface in vehicle_surfaces for final_surface in final_surfaces): continue else: to_consider.add(non_guaranteed_si) else: sis_must_include = self._get_must_include_sis(priority, group_id, existing_si=existing_si) to_consider = set() if allow_posture_providers: additional_posture_sis = set() for si in sis_must_include: owned_posture = self.sim.posture_state.get_source_or_owned_posture_for_si(si) if owned_posture is None: continue if owned_posture.track != postures.PostureTrack.BODY: continue source_interaction = owned_posture.source_interaction if not source_interaction is None: if source_interaction.is_finishing: continue additional_posture_sis.add(source_interaction) sis_must_include.update(additional_posture_sis) additional_posture_sis.clear() total_constraint = Anywhere() included_carryables = set() for si_must_include in sis_must_include: if si_must_include.is_finishing: continue if not si_must_include is to_exclude: if si_must_include is existing_si: continue if existing_si is not None and existing_si.group_id == si_must_include.group_id: continue my_role = si_must_include.get_participant_type(self.sim) if existing_si is not None: existing_participant_type = existing_si.get_participant_type(self.sim) if not self.are_sis_compatible(si_must_include, existing_si, my_role, existing_participant_type, ignore_geometry=True): return (Nowhere('SIState.get_combined_constraint, Two SIs are incompatible: SI_A: {}, SI_B: {}', si_must_include, existing_si), sis_must_include) si_constraint = si_must_include.constraint_intersection(participant_type=my_role, posture_state=posture_state) if existing_si is not None: if existing_si.should_rally or existing_si.relocate_main_group: if si_must_include.is_social: if si_must_include.social_group is not None: if si_must_include.social_group is si_must_include.sim.get_main_group(): si_constraint = si_constraint.generate_posture_only_constraint() si_constraint = si_constraint.apply_posture_state(None, existing_si.get_constraint_resolver(None, participant_type=participant_type)) if existing_constraint is not None: si_constraint = si_constraint.apply(existing_constraint) test_constraint = total_constraint.intersect(si_constraint) if not test_constraint.valid: break carry_target = si_must_include.targeted_carryable if carry_target is not None: if len(included_carryables) == 2 and carry_target not in included_carryables: continue included_carryables.add(carry_target) total_constraint = test_constraint included_sis.add(si_must_include) if len(included_carryables) == 2: if existing_si is not None: existing_carry_target = existing_si.carry_target if existing_carry_target is not None: if existing_carry_target not in included_carryables: total_constraint = Nowhere('Cannot include more than two interactions that are carrying objects.') if included_sis != sis_must_include: total_constraint = Nowhere('Unable to combine SIs that are must include.') if not total_constraint.valid: return (total_constraint, included_sis) if total_constraint.tentative or existing_constraint is not None and existing_constraint.tentative: return (total_constraint, included_sis) if to_consider: for si in self._sis_sorted(to_consider): if si is to_exclude: continue if not self._common_included_si_tests(si): continue my_role = si.get_participant_type(self.sim) if existing_si is not None: existing_participant_type = existing_si.get_participant_type(self.sim) if not self.are_sis_compatible(si, existing_si, my_role, existing_participant_type, ignore_geometry=True): continue else: si_constraint = si.constraint_intersection(participant_type=my_role, posture_state=posture_state) if existing_si is not None: si_constraint = si_constraint.apply_posture_state(None, existing_si.get_constraint_resolver(None, participant_type=participant_type)) if si_constraint.tentative: si_constraint = si.constraint_intersection(participant_type=my_role, posture_state=DEFAULT) test_constraint = total_constraint.intersect(si_constraint) if existing_constraint is not None: test_constraint_plus_existing = test_constraint.intersect(existing_constraint) if test_constraint_plus_existing.valid: if test_constraint_plus_existing.tentative: continue test_constraint = test_constraint.apply(existing_constraint) if test_constraint.valid: total_constraint = test_constraint included_sis.add(si) if total_constraint.tentative: break if test_constraint.valid: total_constraint = test_constraint included_sis.add(si) if total_constraint.tentative: break if allow_posture_providers: additional_posture_sis = set() for si in included_sis: owned_posture = self.sim.posture_state.get_source_or_owned_posture_for_si(si) if owned_posture is not None: if owned_posture.source_interaction not in included_sis: if owned_posture.track == postures.PostureTrack.BODY: additional_posture_sis.add(owned_posture.source_interaction) included_sis.update(additional_posture_sis) if include_existing_constraint: if existing_constraint is not None: total_constraint = total_constraint.intersect(existing_constraint) return (total_constraint, included_sis)
def get_constraint(self, sim): return Anywhere()
def make_constraint_default(cls, *args, **kwargs): return Anywhere()
def _los_constraint(self): return Anywhere()