SAMSON Forum
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • SAMSON Connect
    • Get SAMSON

    Crashes with SBParticleSystem

    Simulation
    2
    2
    2187
    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.
    • K
      Khoa last edited by

      This piece of code that I used crashes SAMSON 0.7.0:

      void MyClass::myFunction(const SBNodeIndexer& nodeIndexer) {
            // Create particle system
            SBParticleSystem particleSystem(nodeIndexer);
      }
      

      While the following one does not crash

      void MyClass::myFunction(const SBNodeIndexer& nodeIndexer) {
            // Create particle system
            SBPointer<SBParticleSystem> particleSystem(new SBParticleSystem(nodeIndexer));
      }
      
      1 Reply Last reply Reply Quote 0
      • Admin
        Admin last edited by Admin

        Hi Khoa, yes, it's always better to create nodes on the heap instead of the stack (i.e. with new). Therefore, you should use a SAMSON pointer (SBPointer) to hold it and destroy the node automatically when the variable gets out of scope.

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