Chromium Code Reviews

Side by Side Diff: import/cross/collada.cc

Issue 159168: This fixes a number of things that are warnings in the Mac compiler.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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 147 matching lines...)
158 // Parameters: 158 // Parameters:
159 // pack: The pack into which the scene objects will be placed. 159 // pack: The pack into which the scene objects will be placed.
160 // Returns true on success. 160 // Returns true on success.
161 Collada::Collada(Pack* pack, const Options& options) 161 Collada::Collada(Pack* pack, const Options& options)
162 : service_locator_(pack->service_locator()), 162 : service_locator_(pack->service_locator()),
163 pack_(pack), 163 pack_(pack),
164 options_(options), 164 options_(options),
165 dummy_effect_(NULL), 165 dummy_effect_(NULL),
166 dummy_material_(NULL), 166 dummy_material_(NULL),
167 instance_root_(NULL), 167 instance_root_(NULL),
168 collada_zip_archive_(NULL),
168 cull_enabled_(false), 169 cull_enabled_(false),
169 cull_front_(false), 170 cull_front_(false),
170 front_cw_(false), 171 front_cw_(false),
171 collada_zip_archive_(NULL),
172 unique_filename_counter_(0) { 172 unique_filename_counter_(0) {
173 } 173 }
174 174
175 Collada::~Collada() { 175 Collada::~Collada() {
176 delete collada_zip_archive_; 176 delete collada_zip_archive_;
177 } 177 }
178 178
179 void Collada::ClearData() { 179 void Collada::ClearData() {
180 textures_.clear(); 180 textures_.clear();
181 original_data_.clear(); 181 original_data_.clear();
(...skipping 319 matching lines...)
501 if (fcd_curve != NULL) { 501 if (fcd_curve != NULL) {
502 FunctionEval* function_eval = pack_->Create<FunctionEval>(); 502 FunctionEval* function_eval = pack_->Create<FunctionEval>();
503 BindParams(function_eval, FunctionEval::kInputParamName, animation_input); 503 BindParams(function_eval, FunctionEval::kInputParamName, animation_input);
504 504
505 Curve* curve = pack_->Create<Curve>(); 505 Curve* curve = pack_->Create<Curve>();
506 function_eval->set_function_object(curve); 506 function_eval->set_function_object(curve);
507 507
508 curve->set_pre_infinity(ConvertInfinity(fcd_curve->GetPreInfinity())); 508 curve->set_pre_infinity(ConvertInfinity(fcd_curve->GetPreInfinity()));
509 curve->set_post_infinity(ConvertInfinity(fcd_curve->GetPostInfinity())); 509 curve->set_post_infinity(ConvertInfinity(fcd_curve->GetPostInfinity()));
510 510
511 for (int i = 0; i != fcd_curve->GetKeyCount(); ++i) { 511 for (unsigned int i = 0; i != fcd_curve->GetKeyCount(); ++i) {
512 FCDAnimationKey* fcd_key = fcd_curve->GetKey(i); 512 FCDAnimationKey* fcd_key = fcd_curve->GetKey(i);
513 switch (fcd_key->interpolation) { 513 switch (fcd_key->interpolation) {
514 case FUDaeInterpolation::STEP: 514 case FUDaeInterpolation::STEP:
515 BuildStepKey(curve, fcd_key, output_scale); 515 BuildStepKey(curve, fcd_key, output_scale);
516 break; 516 break;
517 case FUDaeInterpolation::BEZIER: 517 case FUDaeInterpolation::BEZIER:
518 BuildBezierKey(curve, static_cast<FCDAnimationKeyBezier*>(fcd_key), 518 BuildBezierKey(curve, static_cast<FCDAnimationKeyBezier*>(fcd_key),
519 output_scale); 519 output_scale);
520 break; 520 break;
521 default: 521 default:
(...skipping 983 matching lines...)
1505 source_stream.semantic(), 1505 source_stream.semantic(),
1506 source_stream.semantic_index(), 1506 source_stream.semantic_index(),
1507 dest_fields[ii], 1507 dest_fields[ii],
1508 0)) { 1508 0)) {
1509 O3D_ERROR(service_locator_) 1509 O3D_ERROR(service_locator_)
1510 << "could not SetVertexStream on StreamBank '" 1510 << "could not SetVertexStream on StreamBank '"
1511 << new_stream_bank->name() << "'"; 1511 << new_stream_bank->name() << "'";
1512 return NULL; 1512 return NULL;
1513 } 1513 }
1514 } 1514 }
1515 default:
1516 // do nothing
1517 break;
1515 } 1518 }
1516 } 1519 }
1517 if (!copied) { 1520 if (!copied) {
1518 // It's a shared field, copy it to the shared buffer. 1521 // It's a shared field, copy it to the shared buffer.
1519 source_fields[ii] = shared_buffer->CreateField(field.GetClass(), 1522 source_fields[ii] = shared_buffer->CreateField(field.GetClass(),
1520 field.num_components()); 1523 field.num_components());
1521 new_stream_bank->SetVertexStream(source_stream.semantic(), 1524 new_stream_bank->SetVertexStream(source_stream.semantic(),
1522 source_stream.semantic_index(), 1525 source_stream.semantic_index(),
1523 source_fields[ii], 1526 source_fields[ii],
1524 0); 1527 0);
(...skipping 68 matching lines...)
1593 // Bind streams 1596 // Bind streams
1594 skin_eval->SetVertexStream(source_stream.semantic(), 1597 skin_eval->SetVertexStream(source_stream.semantic(),
1595 source_stream.semantic_index(), 1598 source_stream.semantic_index(),
1596 source_field, 1599 source_field,
1597 0); 1600 0);
1598 new_stream_bank->BindStream(skin_eval, 1601 new_stream_bank->BindStream(skin_eval,
1599 source_stream.semantic(), 1602 source_stream.semantic(),
1600 source_stream.semantic_index()); 1603 source_stream.semantic_index());
1601 break; 1604 break;
1602 } 1605 }
1606 default:
1607 // do nothing
1608 break;
1603 } 1609 }
1604 } 1610 }
1605 if (!copied) { 1611 if (!copied) {
1606 Field* source_field = source_fields[ii]; 1612 Field* source_field = source_fields[ii];
1607 source_field->Copy(field); 1613 source_field->Copy(field);
1608 } 1614 }
1609 } 1615 }
1610 1616
1611 // Set all primitives to use new stream bank. 1617 // Set all primitives to use new stream bank.
1612 for (unsigned ii = 0; ii < elements.size(); ++ii) { 1618 for (unsigned ii = 0; ii < elements.size(); ++ii) {
(...skipping 794 matching lines...)
2407 } 2413 }
2408 case FUDaePassStateFaceType::BACK: { 2414 case FUDaePassStateFaceType::BACK: {
2409 cull_front_ = false; 2415 cull_front_ = false;
2410 break; 2416 break;
2411 } 2417 }
2412 case FUDaePassStateFaceType::FRONT_AND_BACK: { 2418 case FUDaePassStateFaceType::FRONT_AND_BACK: {
2413 O3D_ERROR(service_locator_) 2419 O3D_ERROR(service_locator_)
2414 << "FRONT_AND_BACK culling is unsupported"; 2420 << "FRONT_AND_BACK culling is unsupported";
2415 break; 2421 break;
2416 } 2422 }
2423 case FUDaePassStateFaceType::INVALID:
2424 O3D_ERROR(service_locator_) << "INVALID culling type";
2425 break;
2417 } 2426 }
2418 UpdateCullingState(state); 2427 UpdateCullingState(state);
2419 break; 2428 break;
2420 } 2429 }
2421 case FUDaePassState::DEPTH_FUNC: { 2430 case FUDaePassState::DEPTH_FUNC: {
2422 State::Comparison function = ConvertComparisonFunction( 2431 State::Comparison function = ConvertComparisonFunction(
2423 service_locator_, 2432 service_locator_,
2424 GetStateValue<FUDaePassStateFunction::Function>(pass_state, 0)); 2433 GetStateValue<FUDaePassStateFunction::Function>(pass_state, 0));
2425 SetIntState(state, State::kZComparisonFunctionParamName, function); 2434 SetIntState(state, State::kZComparisonFunctionParamName, function);
2426 break; 2435 break;
(...skipping 171 matching lines...)
2598 case FUDaePassState::LINE_SMOOTH_ENABLE: { 2607 case FUDaePassState::LINE_SMOOTH_ENABLE: {
2599 bool value = GetStateValue<bool>(pass_state, 0); 2608 bool value = GetStateValue<bool>(pass_state, 0);
2600 SetBoolState(state, State::kLineSmoothEnableParamName, value); 2609 SetBoolState(state, State::kLineSmoothEnableParamName, value);
2601 break; 2610 break;
2602 } 2611 }
2603 case FUDaePassState::STENCIL_TEST_ENABLE: { 2612 case FUDaePassState::STENCIL_TEST_ENABLE: {
2604 bool value = GetStateValue<bool>(pass_state, 0); 2613 bool value = GetStateValue<bool>(pass_state, 0);
2605 SetBoolState(state, State::kStencilEnableParamName, value); 2614 SetBoolState(state, State::kStencilEnableParamName, value);
2606 break; 2615 break;
2607 } 2616 }
2617 default:
2618 // do nothing
2619 break;
2608 } 2620 }
2609 } 2621 }
2610 2622
2611 // Converts an FCollada texture sampler wrap mode to an O3D Sampler 2623 // Converts an FCollada texture sampler wrap mode to an O3D Sampler
2612 // AddressMode. 2624 // AddressMode.
2613 static Sampler::AddressMode ConvertSamplerAddressMode( 2625 static Sampler::AddressMode ConvertSamplerAddressMode(
2614 FUDaeTextureWrapMode::WrapMode wrap_mode) { 2626 FUDaeTextureWrapMode::WrapMode wrap_mode) {
2615 switch (wrap_mode) { 2627 switch (wrap_mode) {
2616 case FUDaeTextureWrapMode::WRAP: 2628 case FUDaeTextureWrapMode::WRAP:
2617 return Sampler::WRAP; 2629 return Sampler::WRAP;
(...skipping 158 matching lines...)
2776 size_t pcount = material->GetEffectParameterCount(); 2788 size_t pcount = material->GetEffectParameterCount();
2777 // TODO(o3d): This test (for determining if we used the 2789 // TODO(o3d): This test (for determining if we used the
2778 // programmable profile or the fixed-func profile) is not very robust. 2790 // programmable profile or the fixed-func profile) is not very robust.
2779 // Remove this once the Material changes are in. 2791 // Remove this once the Material changes are in.
2780 if (pcount > 0) { 2792 if (pcount > 0) {
2781 for (size_t i = 0; i < pcount; ++i) { 2793 for (size_t i = 0; i < pcount; ++i) {
2782 FCDEffectParameter* p = material->GetEffectParameter(i); 2794 FCDEffectParameter* p = material->GetEffectParameter(i);
2783 LOG_ASSERT(p); 2795 LOG_ASSERT(p);
2784 String param_name(p->GetReference()); 2796 String param_name(p->GetReference());
2785 // Check for an effect binding 2797 // Check for an effect binding
2786 FCDEffect* effect = material->GetEffect();
2787 FCDEffectProfileFX* profile_fx = FindProfileFX(material->GetEffect()); 2798 FCDEffectProfileFX* profile_fx = FindProfileFX(material->GetEffect());
2788 if (profile_fx) { 2799 if (profile_fx) {
2789 FCDEffectTechnique* technique = profile_fx->GetTechnique(0); 2800 FCDEffectTechnique* technique = profile_fx->GetTechnique(0);
2790 if (technique->GetPassCount() > 0) { 2801 if (technique->GetPassCount() > 0) {
2791 FCDEffectPass* pass = technique->GetPass(0); 2802 FCDEffectPass* pass = technique->GetPass(0);
2792 for (size_t j = 0; j < pass->GetShaderCount(); ++j) { 2803 for (size_t j = 0; j < pass->GetShaderCount(); ++j) {
2793 FCDEffectPassShader* shader = pass->GetShader(j); 2804 FCDEffectPassShader* shader = pass->GetShader(j);
2794 FCDEffectPassBind* bind = 2805 FCDEffectPassBind* bind =
2795 shader->FindBindingReference(p->GetReference()); 2806 shader->FindBindingReference(p->GetReference());
2796 if (bind) { 2807 if (bind) {
(...skipping 43 matching lines...)
2840 SetParamFromFCEffectParam(param_object, 2851 SetParamFromFCEffectParam(param_object,
2841 kMaterialParamNameShininess, 2852 kMaterialParamNameShininess,
2842 effect_standard->GetShininessParam()); 2853 effect_standard->GetShininessParam());
2843 SetParamFromFCEffectParam(param_object, 2854 SetParamFromFCEffectParam(param_object,
2844 kMaterialParamNameSpecularFactor, 2855 kMaterialParamNameSpecularFactor,
2845 effect_standard->GetSpecularFactorParam()); 2856 effect_standard->GetSpecularFactorParam());
2846 } 2857 }
2847 } 2858 }
2848 } 2859 }
2849 } // namespace o3d 2860 } // namespace o3d
OLDNEW

Powered by Google App Engine