Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11735 for code


Ignore:
Timestamp:
Feb 11, 2018, 7:19:57 PM (7 years ago)
Author:
landauf
Message:

[AsteroidMining_HS17] fixed a bunch of memory leaks

Location:
code/branches/Presentation_HS17_merge/src/modules/asteroidmining
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc

    r11734 r11735  
    177177        reborn->setVelocity(this->getVelocity());
    178178        // reborn->setAngularVelocity(this->getAngularVelocity()); // Add all other stuff, too?
    179         (void)reborn; // avoid compiler warning
    180179
    181180        this->bAlive_ = false;
     
    361360    for(int fisch = 0; fisch<num; ++fisch){
    362361
    363         Vector3* pos = new Vector3(0,0,0); // Position offset
     362        Vector3 pos = Vector3::ZERO; // Position offset
    364363        if(num > 1){// not required if there-s just one child
    365364            float r = masses[fisch]/rScaling;
    366             pos = new Vector3(r*sin(theta[fisch])*cos(phi[fisch]), r*sin(theta[fisch])*sin(phi[fisch]), r*cos(theta[fisch])); // convert spheric coordinates to vector
     365            pos = Vector3(r*sin(theta[fisch])*cos(phi[fisch]), r*sin(theta[fisch])*sin(phi[fisch]), r*cos(theta[fisch])); // convert spheric coordinates to vector
    367366        }
    368367       
    369         AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + *pos, this->dropStuff);
     368        AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + pos, this->dropStuff);
    370369        child->setVelocity(this->getVelocity());
    371 
    372         if(child == nullptr){
    373             orxout(internal_error, context::pickups) << "Weird, can't create new AsteroidMinable." << endl;
    374         }
    375370
    376371    }
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.cc

    r11732 r11735  
    8080
    8181        this->mDensity = 0.3;
     82        this->foggy = true;
    8283        this->fogDensity = 0.5;
    8384
     
    113114            }
    114115           
    115             Vector3* pos = new Vector3(radius*cos(sepp)*sin(globi), radius*sin(sepp)*sin(globi), radius*cos(globi));
    116             new SpicedAsteroidField(this->context, this->position + *pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity);
     116            Vector3 pos(radius*cos(sepp)*sin(globi), radius*sin(sepp)*sin(globi), radius*cos(globi));
     117            new SpicedAsteroidField(this->context, this->position + pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity);
    117118           
    118119        }
  • code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidField.cc

    r11667 r11735  
    107107        int pZ;
    108108
    109         Vector3* relPos;
    110 
    111109        for(int gertrud = 0; gertrud<count; ++gertrud){
    112110
     
    119117            pY = round(rnd()*2*this->radius) - radius;
    120118            pZ = round(rnd()*2*this->radius) - radius;
    121             relPos = new Vector3(pX, pY, pZ);
    122             a->setPosition(this->position + *relPos);
     119            Vector3 relPos(pX, pY, pZ);
     120            a->setPosition(this->position + relPos);
    123121
    124122            bool spiced = (rnd() < (this->mDensity)); // Whether the asteroid does drop pickups etc.
     
    128126           
    129127            // Fog is iplemented with billboards (as in asteroidField.lua, that bloke had the idea)
    130             Billboard* bb;
    131128            if(this->foggy && mod(gertrud, 5) == 0){
    132                 bb = new Billboard(this->context);
    133                 bb->setPosition(this->position + *relPos);
     129                Billboard* bb = new Billboard(this->context);
     130                bb->setPosition(this->position + relPos);
    134131                bb->setMaterial("Smoke/Smoke");
    135132                bb->setScale(size);
Note: See TracChangeset for help on using the changeset viewer.