| 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 30 matching lines...) Expand all Loading... |
| 41 namespace o3d { | 41 namespace o3d { |
| 42 | 42 |
| 43 O3D_DEFN_CLASS(Skin, NamedObject); | 43 O3D_DEFN_CLASS(Skin, NamedObject); |
| 44 O3D_DEFN_CLASS(ParamSkin, RefParamBase); | 44 O3D_DEFN_CLASS(ParamSkin, RefParamBase); |
| 45 O3D_DEFN_CLASS(SkinEval, VertexSource); | 45 O3D_DEFN_CLASS(SkinEval, VertexSource); |
| 46 | 46 |
| 47 const char *Skin::kSerializationID = "SKIN"; | 47 const char *Skin::kSerializationID = "SKIN"; |
| 48 | 48 |
| 49 Skin::Skin(ServiceLocator* service_locator) | 49 Skin::Skin(ServiceLocator* service_locator) |
| 50 : NamedObject(service_locator), | 50 : NamedObject(service_locator), |
| 51 weak_pointer_manager_(this), | |
| 52 highest_matrix_index_(0), | 51 highest_matrix_index_(0), |
| 53 highest_influences_(0), | 52 highest_influences_(0), |
| 54 info_valid_(false) { | 53 info_valid_(false), |
| 54 weak_pointer_manager_(this) { |
| 55 } | 55 } |
| 56 | 56 |
| 57 const Skin::Influences* Skin::GetVertexInfluences(unsigned vertex_index) const { | 57 const Skin::Influences* Skin::GetVertexInfluences(unsigned vertex_index) const { |
| 58 return (vertex_index < influences_array_.size()) ? | 58 return (vertex_index < influences_array_.size()) ? |
| 59 &influences_array_[vertex_index] : NULL; | 59 &influences_array_[vertex_index] : NULL; |
| 60 } | 60 } |
| 61 | 61 |
| 62 void Skin::SetVertexInfluences(unsigned vertex_index, | 62 void Skin::SetVertexInfluences(unsigned vertex_index, |
| 63 const Skin::Influences& influences) { | 63 const Skin::Influences& influences) { |
| 64 if (influences_array_.size() <= vertex_index) { | 64 if (influences_array_.size() <= vertex_index) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 inverse_bind_pose_matrices_.resize(index + 1, Matrix4::identity()); | 107 inverse_bind_pose_matrices_.resize(index + 1, Matrix4::identity()); |
| 108 } | 108 } |
| 109 inverse_bind_pose_matrices_[index] = matrix; | 109 inverse_bind_pose_matrices_[index] = matrix; |
| 110 } | 110 } |
| 111 | 111 |
| 112 ObjectBase::Ref Skin::Create(ServiceLocator* service_locator) { | 112 ObjectBase::Ref Skin::Create(ServiceLocator* service_locator) { |
| 113 return ObjectBase::Ref(new Skin(service_locator)); | 113 return ObjectBase::Ref(new Skin(service_locator)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 SkinEval::StreamInfo::StreamInfo() | 116 SkinEval::StreamInfo::StreamInfo() |
| 117 : data_(NULL), | 117 : compute_function_(NULL), |
| 118 buffer_(NULL), | 118 copy_function_(NULL), |
| 119 values_(NULL), | 119 data_(NULL), |
| 120 stride_(0), | 120 buffer_(NULL), |
| 121 compute_function_(NULL), | 121 values_(NULL), |
| 122 copy_function_(NULL) { | 122 stride_(0) { |
| 123 } | 123 } |
| 124 | 124 |
| 125 namespace { | 125 namespace { |
| 126 | 126 |
| 127 void ComputeFloat3AsVector3(float* destination, | 127 void ComputeFloat3AsVector3(float* destination, |
| 128 const float* source, | 128 const float* source, |
| 129 const Matrix4& matrix) { | 129 const Matrix4& matrix) { |
| 130 Vector4 result(matrix * Vector3(source[0], source[1], source[2])); | 130 Vector4 result(matrix * Vector3(source[0], source[1], source[2])); |
| 131 destination[0] = result.getElem(0); | 131 destination[0] = result.getElem(0); |
| 132 destination[1] = result.getElem(1); | 132 destination[1] = result.getElem(1); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 const uint8 *data = raw_data->GetDataAs<uint8>(offset); | 640 const uint8 *data = raw_data->GetDataAs<uint8>(offset); |
| 641 if (!data) { | 641 if (!data) { |
| 642 return false; | 642 return false; |
| 643 } | 643 } |
| 644 | 644 |
| 645 MemoryReadStream stream(data, length); | 645 MemoryReadStream stream(data, length); |
| 646 return LoadFromBinaryData(&stream); | 646 return LoadFromBinaryData(&stream); |
| 647 } | 647 } |
| 648 | 648 |
| 649 } // namespace o3d | 649 } // namespace o3d |
| OLD | NEW |