hyperPad hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Which more expensive: Broadcast or Conditional?

    Scheduled Pinned Locked Moved
    Help and Support
    5
    14
    521
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • iTap DevelopmentI
      iTap Development @Deeeds
      last edited by

      @Deeeds why bother with the broadcast? Why not just have the collide behavior in the object you are broadcasting to?

      D 1 Reply Last reply Reply Quote 0
      • D
        Deeeds @iTap Development
        last edited by

        @iTap-Development It's just an example to make it clear that I'm considering using a LOT of broadcasting, and have already become lazy in relying on it for code organisation.

        The question is not about a specific problem: I'm asking the relative cost of using broadcasts versus other approaches to organising and distributing code.

        KamdroidK 1 Reply Last reply Reply Quote 0
        • KamdroidK
          Kamdroid @Deeeds
          last edited by Kamdroid

          @Deeeds You might want to ask the developers.

          I would think that a broadcast/broadcast receive would impact more than a conditional, since broadcast receive behaviours are always waiting for a message to be broadcasted to them.

          If you end up getting an answer, let me know too.

          D 1 Reply Last reply Reply Quote 0
          • D
            Deeeds @Kamdroid
            last edited by

            @Kamdroid I was kind of hoping they just read these forums as a matter of course. It's not like there's much in here ;)

            Except for my dribbles and rants.

            I'm not so sure about the listeners actively listening. This might be just a metaphor being used. They're probably sitting in an array or dictionary that's messaged only when a "broadcast" is sent, meaning highly efficient. Possibly more so than conditionals.

            boring story approaching: A friend of mine, a few years ago, spent a huge amount of time teaching me to not use ifs because he'd found them to be a bit of a drag in high frequency stuff. We were doing lots of particles, where the volume of activity was enormous, but we always wanted more. More particles = good! It was all C++ and he had some pretty tight stats on it all. Made me a believer, even if I didn't fully understand where he was headed with it all.

            The bottom line was polymorphism being used correctly, I'd dare say. He is a bright guy. I'm just a designer, but it fascinated me that he'd figure how to remove ifs like they were parasites.

            1 Reply Last reply Reply Quote 0
            • HamedH
              Hamed Admin
              last edited by

              Broadcasts are really fast. They are much faster than using collisions or something like that. @Deeeds it works like you think it is.

              D 1 Reply Last reply Reply Quote 1
              • D
                Deeeds @Hamed
                last edited by

                @Hamed BEST NEWS TODAY! I can and will base most of what I'm doing around them, then. And use them like function/method calls all over the place. I thought this might have been one of the ways you were making them useful.

                THANK YOU!!! Way to go!

                1 Reply Last reply Reply Quote 0
                • HamedH
                  Hamed Admin
                  last edited by

                  @Deeeds The only thing i would suggest doing is leaving little comments for your self otherwise you will have a bunch of broadcasts and receives that you don't remember what they're for.

                  D Aidan_FireA 2 Replies Last reply Reply Quote 0
                  • D
                    Deeeds @Hamed
                    last edited by

                    @Hamed Yeah, I have a Notes file with that sort of gunk. I've been meaning to request picking Event Keys operate like Behaviour On/Off where there's a long list of all possible ones, by alphabetical order, by object/original origin.

                    1 Reply Last reply Reply Quote 0
                    • Aidan_FireA
                      Aidan_Fire @Hamed
                      last edited by

                      @Hamed Are broadcasts expensive at all? For example, in my 3D project the faces of a shape have to conform to 3 points, I’ve done this (messily) by colliding with those 3 points (they’re in a tag) and then basically getting the position on a timer of the object it collided with. Is this at all more efficient that constantly broadcasting dynamic messages?

                      iTap DevelopmentI 1 Reply Last reply Reply Quote 0
                      • iTap DevelopmentI
                        iTap Development @Aidan_Fire
                        last edited by

                        @Aidan-Oxley I would think broadcast would be better. Because otherwise you have objects with collisions, but you wouldn’t need that if you didn’t use collide.

                        1 Reply Last reply Reply Quote 0
                        • HamedH
                          Hamed Admin
                          last edited by

                          The only expense is having a lot of logic in the receive message side. Physics engine is much slower to do those kind of tasks.

                          Aidan_FireA 1 Reply Last reply Reply Quote 0
                          • Aidan_FireA
                            Aidan_Fire @Hamed
                            last edited by

                            @Hamed The collision happens once. The face collided with one point, the turns off that collision and moves to another point. It does this 3 times with 3 separate collision behaviours. Once it’s done, it waits until everything else has finished loading, then runs a timer on the behaviours underneath the collisions so that it can get information on those 3 objects. So this is more efficient than broadcasting a message on a timer containing an objects position right?

                            1 Reply Last reply Reply Quote 0
                            • HamedH
                              Hamed Admin
                              last edited by

                              No broadcasting is still much faster. You can avoid timers and delays and collision take multiple time steps

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post