| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 Shape::Shape(ServiceLocator* service_locator) | 43 Shape::Shape(ServiceLocator* service_locator) |
| 44 : ParamObject(service_locator) { | 44 : ParamObject(service_locator) { |
| 45 } | 45 } |
| 46 | 46 |
| 47 ObjectBase::Ref Shape::Create(ServiceLocator* service_locator) { | 47 ObjectBase::Ref Shape::Create(ServiceLocator* service_locator) { |
| 48 return ObjectBase::Ref(new Shape(service_locator)); | 48 return ObjectBase::Ref(new Shape(service_locator)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 Shape::~Shape() { | 51 Shape::~Shape() { |
| 52 ElementRefArray copy(elements_.begin(), elements_.end()); |
| 52 // Unregister any Elements that might think they own us. | 53 // Unregister any Elements that might think they own us. |
| 53 ElementRefArray::iterator iter, end = elements_.end(); | 54 ElementRefArray::iterator iter, end = copy.end(); |
| 54 for (iter = elements_.begin(); iter != end; ++iter) { | 55 for (iter = copy.begin(); iter != end; ++iter) { |
| 55 if (iter->Get()) { | 56 if (iter->Get()) { |
| 56 iter->Get()->SetOwner(0); | 57 iter->Get()->SetOwner(0); |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 } | 60 } |
| 60 | 61 |
| 61 // Adds a element do this shape. | 62 // Adds a element do this shape. |
| 62 void Shape::AddElement(Element* element) { | 63 void Shape::AddElement(Element* element) { |
| 63 elements_.push_back(Element::Ref(element)); | 64 elements_.push_back(Element::Ref(element)); |
| 64 } | 65 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 const DrawElementRefArray& draw_elements = element->GetDrawElementRefs(); | 113 const DrawElementRefArray& draw_elements = element->GetDrawElementRefs(); |
| 113 if (std::find_if(draw_elements.begin(), | 114 if (std::find_if(draw_elements.begin(), |
| 114 draw_elements.end(), | 115 draw_elements.end(), |
| 115 FindByMaterial(material)) == draw_elements.end()) { | 116 FindByMaterial(material)) == draw_elements.end()) { |
| 116 elements_[pp]->CreateDrawElement(pack, material); | 117 elements_[pp]->CreateDrawElement(pack, material); |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 121 } // namespace o3d | 122 } // namespace o3d |
| OLD | NEW |