With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
Discuss & improve the game engine.

Moderators: Tequila, sparcdr, torhu

Weapon fire code refactoring

Postby Tequila » Tue Sep 29, 2009 12:47 am

Weapon fire code refactoring ? 8O What's that ?

He he, I'm just talking about the last revision I committed today: 1.1 branch rev310.

So here is my published comment for that r310 (with original typos :)):
sg_tequila wrote:Weapon fire code refactoring:
- Added Weapon_Trace API to easily add trace debugging entity in debug build
It is now possible to visually debug trace on client side (only in debug build)
- Added g_debugWeapon cvar in debug build
- Review some code in prevision to higher refactoring:
FireWeapon & ShotgunPellet should share some code in next update
Weapon fix:
- Really check we are not shooting ourself
Media added:
- Added shader and picture to draw trace debuggung entities
- Added sg_developer.pk3 PAK creation and copy in copyfiles-debug target


So I rewrote some part of the API, that's a real weapon fire code refactoring. That wasn't my real goal at the beginning, but I was checking some "entities" problems to have my final "stucking bug patch" working for the next beta release... And I triggered some bugs... Yeah, that's my job :D I like bugs as they're scratching me :D
Then to beat that new bugs, I wanted new tools around the weapon fire APIs and the major one for which I published this rev310 is the availability to visually debug the trace system... What's that ? That's the bullet collision calculations toward enemies and windows to break ;)

Anyone involved should review the code and help as he can.

That weapon fire code refactoring is a first stage as it still show me many trace bugs... Especially in the shoot through walls stuff... So it's really time to fix all that old and nasty bugs, guys... My stucking bug patch will wait.

To illustrate, I uploaded a video on the video section of my Moddb profile:


I'll try also to upload it on my Youtube profile.

I'll prepare another video with what I still noticed but if any coder want to help now, you should know BG_ShootThruWall() API from bg_misc.c is completly bugged and really need a big refactoring.

Few bugs to fix because of BG_ShootThruWall:
1. Can't shoot through doors and some other entities, like first shoot in a window won't go through...
2. Can't shoot through curves
3. You can shoot through 3 to 4 solid walls (not wood), here that's the thickness balance which seems bad.

For the ones, wanting to test the trace debug system, you'll need to build a debug release as that system won't be released in official releases. Then you'll have to create a sg_developer.pk3 with the /misc/media stuffs I added (linux users should use copyfiles-debug target). Setting g_debugWeapon will do the rest. Hum I really want a wiki to describe precisely all the process :P
8)
User avatar
Tequila
SG Team
 
Posts: 1088
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby torhu » Tue Sep 29, 2009 2:17 am

I'll bet you can make a pretty cool laser show if you use that feature with the gatling. :lol:
In game: =SG=monSter
Monster Browser
User avatar
torhu
SG Team
 
Posts: 1110
Joined: Thu Jan 06, 2005 8:12 pm
Location: Norway



Postby Pardner » Tue Sep 29, 2009 2:23 am

or the shotguns!

it looks like the bullet hit decal is of from the actual bullet trace?

Image
Image
User avatar
Pardner
SG Team
 
Posts: 1786
Joined: Fri Nov 18, 2005 5:48 am
Location: MD, USA



Postby Ugly » Tue Sep 29, 2009 8:32 am

Neat. I have been thinking that something like this could be built into a training level to let he new folks work out how the weapons work.
User avatar
Ugly
Pistolero
 
Posts: 38
Joined: Fri Jan 02, 2009 7:55 pm



Postby Tequila » Tue Sep 29, 2009 9:39 am

Pardner wrote:or the shotguns!

it looks like the bullet hit decal is of from the actual bullet trace?

Indeed :)

About the decal, network traffic is optimized and vectors are rounded to integer. So the client side shown traces are approximated. Btw they are not on the server side, so don't worry about this. You should know the trace "beam" is approximatively 2 units large... so 1 unit between the trace middle and the light edge.

Ugly wrote:Neat. I have been thinking that something like this could be built into a training level to let he new folks work out how the weapons work.
That could be an idea, but for now I just prefer such stuff for developers only as it can be used to cheat... by just showing you for 30 seconds where you were ;)

Also I uploaded the video on youtube which one I just annotated:
User avatar
Tequila
SG Team
 
Posts: 1088
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Joe Kari » Tue Sep 29, 2009 1:56 pm

Yeah, fine debug feature !!!
User avatar
Joe Kari
SG Team
 
Posts: 878
Joined: Sun Sep 16, 2007 8:44 pm
Location: France



Postby torhu » Tue Sep 29, 2009 7:36 pm

I've tried some long distance shooting in el paso using this feature combined with my own patch, and it's a really great way to see the effect of different spread values. Nice job, Tequila. :)
In game: =SG=monSter
Monster Browser
User avatar
torhu
SG Team
 
Posts: 1110
Joined: Thu Jan 06, 2005 8:12 pm
Location: Norway



Postby Tequila » Thu Oct 01, 2009 1:04 am

User avatar
Tequila
SG Team
 
Posts: 1088
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Tequila » Wed Oct 28, 2009 2:14 am

Ugly wrote:Neat. I have been thinking that something like this could be built into a training level to let he new folks work out how the weapons work.

Maybe your dream will be realized ;)
I finally activated the stuff in the 1.1 branch starting from r372. Next beta release will so incorporate that stuff by default.
Btw it was also accidentally built in the current v1.1b1 engine (my mistake, one more...).

You'll be able to test that in single player game by opening your console and set g_debugWeapon to 1.

Btw before releasing that next beta release, we may improve the look and feel of the displayed traces. As you can see, the trace is most like a blue ray. It uses the following trace.jpg picture colorized in blue by the code:
[thumb=http://forum.smokin-guns.org/userpix/1560_trace_1.jpg][timg]1560_trace_1.jpg[/timg][/thumb]
and the following shader:
Code: Select all
weapon_trace
{
   nopicmip

   {
      map textures/developer/trace.jpg
      blendFunc GL_ONE GL_ONE
      rgbGen vertex
   }
}

What do you think ?

If you want to test with current v1.1b1, you'll need the following PK3: sg_developer.pk3
Feel free to edit that PK3 and propose your own here.
8)
User avatar
Tequila
SG Team
 
Posts: 1088
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Sucalakafufu » Wed Oct 28, 2009 4:24 am

so i downloaded the pk3 and put it in my smokinguns folder. and for some reason i still cant use the cvar g_debugWeapon
SG Name: Sucalakafufu
Clan: [CWNN] - Clan With No Name
User avatar
Sucalakafufu
Gunslinger
 
Posts: 239
Joined: Thu Apr 16, 2009 8:59 am



Postby Tequila » Wed Oct 28, 2009 10:35 am

Okay, so which engine and which game versions are you using ? On which platform ?
Report also your console output so we can verify which versions and which PK3 are loaded.
User avatar
Tequila
SG Team
 
Posts: 1088
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby ReD NeCKersoN » Wed Oct 28, 2009 4:57 pm

Tequila wrote:Btw before releasing that next beta release, we may improve the look and feel of the displayed traces.

What sort of improvements are you looking for? A more defined trace?
Image
User avatar
ReD NeCKersoN
SG Team
 
Posts: 3245
Joined: Wed Mar 27, 2002 6:22 am
Location: VA, USA



Postby Sucalakafufu » Wed Oct 28, 2009 7:50 pm

Tequila wrote:Okay, so which engine and which game versions are you using ? On which platform ?
Report also your console output so we can verify which versions and which PK3 are loaded.


im on v1.1b1 on Windows XP

from my console output it seems that its loading the developer pk3 first then overwriting it with something from the other pk3's? thats the only thing i can think of anyway...

Code: Select all
Smokin' Guns 1.1 win_msvc-x86 Oct 18 2009
----- FS_Startup -----
Current search path:
C:\Documents and Settings\Fu\Application Data\Smokin' Guns/smokinguns
C:\Program Files\Smokin' Guns\smokinguns\z_ttstation.pk3 (8 files)
C:\Program Files\Smokin' Guns\smokinguns\zzz_sg_developer.pk3 (2 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_textures0.pk3 (1018 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_sounds.pk3 (278 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_pak1.pk3 (15 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_pak0.pk3 (803 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_maps1.pk3 (21 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_maps0.pk3 (161 files)
C:\Program Files\Smokin' Guns\smokinguns\joekarimat1.pk3 (178 files)
C:\Program Files\Smokin' Guns\smokinguns\alamo1.pk3 (14 files)
C:\Program Files\Smokin' Guns/smokinguns
C:\Program Files\Smokin' Guns\baseq3\pak0.pk3 (107 files)
C:\Program Files\Smokin' Guns/baseq3

----------------------
2605 files in pk3 files


EDIT: something interesting i noticed. in 1.1 the pk3's are loaded in backwards alphabetical order! 0_0 although i just tried renaming the developer pk3 and even though it loaded last i still didnt get that cvar...
SG Name: Sucalakafufu
Clan: [CWNN] - Clan With No Name
User avatar
Sucalakafufu
Gunslinger
 
Posts: 239
Joined: Thu Apr 16, 2009 8:59 am



Postby Tequila » Wed Oct 28, 2009 9:44 pm

ReD NeCKersoN wrote:
Tequila wrote:Btw before releasing that next beta release, we may improve the look and feel of the displayed traces.

What sort of improvements are you looking for? A more defined trace?

Right now, the system is using native RAIL CORE rendering. The rail core is using r_railCoreWidth cvar (6 by default) to draw the picture on the surface defined by the trace origin, trace end and r_railCoreWidth. You can set r_railCoreWidth to 1 to create thiner trace. Btw, if nobody complain about the blue shape, we will keep that.
About the shader, I really don't know if it is correct. I'm more than a noob in shaders.

@ Sucalakafufu: Do you have old binary DLL for the game ? We can't see with your cut console output what is really loaded.
User avatar
Tequila
SG Team
 
Posts: 1088
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Sucalakafufu » Thu Oct 29, 2009 2:14 am

@Tequila: sorry about that. i didnt want to take alot of space with the console output hehe. well im pretty sure mine is the new dll? maybe? heres the full output

Code: Select all
Smokin' Guns 1.1 win_msvc-x86 Oct 18 2009
----- FS_Startup -----
Current search path:
C:\Documents and Settings\Fu\Application Data\Smokin' Guns/smokinguns
C:\Program Files\Smokin' Guns\smokinguns\sg_textures0.pk3 (1018 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_sounds.pk3 (278 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_pak1.pk3 (15 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_pak0.pk3 (803 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_maps1.pk3 (21 files)
C:\Program Files\Smokin' Guns\smokinguns\sg_maps0.pk3 (161 files)
C:\Program Files\Smokin' Guns\smokinguns\joekarimat1.pk3 (178 files)
C:\Program Files\Smokin' Guns\smokinguns\alamo1.pk3 (14 files)
C:\Program Files\Smokin' Guns\smokinguns\ai_sg_developer.pk3 (2 files)
C:\Program Files\Smokin' Guns/smokinguns
C:\Program Files\Smokin' Guns\baseq3\pak0.pk3 (107 files)
C:\Program Files\Smokin' Guns/baseq3

----------------------
2597 files in pk3 files
execing default.cfg
com_zoneMegs will be changed upon restarting.
execing q3config.cfg
execing autoexec.cfg
Hunk_Clear: reset the hunk ok
----- Client Initialization -----
----- Initializing Renderer ----
-------------------------------
Smokin' Guns checks on
QKEY found.
----- Client Initialization Complete -----
----- R_Init -----
SDL using driver "directx"
Initializing OpenGL display
Estimated display aspect: 1.600
...setting mode -1: 1280 800
Using 8/8/8 Color bits, 24 depth, 0 stencil display.
Available modes: '1280x800 640x400 320x240 400x300 480x360 512x384 640x480
800x600 1024x768'
GL_RENDERER: GeForce Go 6150/PCI/SSE2/3DNOW!
Initializing OpenGL extensions
...using GL_EXT_texture_compression_s3tc
...using GL_EXT_texture_env_add
...using GL_ARB_multitexture
...using GL_EXT_compiled_vertex_array
...ignoring GL_EXT_texture_filter_anisotropic

GL_VENDOR: NVIDIA Corporation
GL_RENDERER: GeForce Go 6150/PCI/SSE2/3DNOW!
GL_VERSION: 2.0.1
GL_EXTENSIONS: GL_ARB_color_buffer_float GL_ARB_depth_texture
GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_program_shadow
GL_ARB_fragment_shader GL_ARB_half_float_pixel GL_ARB_imaging
GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query
GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite
GL_ARB_shadow GL_ARB_shader_objects GL_ARB_shading_language_100
GL_ARB_texture_border_clamp GL_ARB_texture_compression
GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine
GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat
GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle
GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program
GL_ARB_vertex_shader GL_ARB_window_pos GL_ATI_draw_buffers
GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc
GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color
GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax
GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader
GL_EXT_depth_bounds_test GL_EXT_draw_range_elements GL_EXT_fog_coord
GL_EXT_framebuffer_object GL_EXT_multi_draw_arrays
GL_EXT_packed_depth_stencil GL_EXT_packed_pixels GL_EXT_pixel_buffer_object
GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color
GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_clear_tag
GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D
GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map
GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3
GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod GL_EXT_texture_lod_bias
GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_sRGB
GL_EXT_timer_query GL_EXT_vertex_array GL_HP_occlusion_test
GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region
GL_NV_blend_square GL_NV_copy_depth_to_color GL_NV_depth_clamp GL_NV_fence
GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_program
GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_half_float
GL_NV_light_max_exponent GL_NV_multisample_filter_hint GL_NV_occlusion_query
GL_NV_packed_depth_stencil GL_NV_pixel_data_range GL_NV_point_sprite
GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2
GL_NV_texgen_reflection GL_NV_texture_compression_vtc
GL_NV_texture_env_combine4 GL_NV_texture_expand_normal
GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2
GL_NV_texture_shader3 GL_NV_vertex_array_range GL_NV_vertex_array_range2
GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2
GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render
GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture
GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control
GL_MAX_TEXTURE_SIZE: 4096
GL_MAX_TEXTURE_UNITS_ARB: 4

PIXELFORMAT: color(24-bits) Z(24-bit) stencil(0-bits)
MODE: -1, 1280 x 800 fullscreen hz:N/A
GAMMA: hardware w/ 0 overbright bits
rendering primitives: single glDrawElements
texturemode: GL_LINEAR_MIPMAP_NEAREST
picmip: 1
texture bits: 0
multitexture: enabled
compiled vertex arrays: enabled
texenv add: enabled
compressed textures: enabled
Initializing Shaders
----- finished R_Init -----
------ Initializing Sound ------
SDL_Init( SDL_INIT_AUDIO )... OK
SDL audio driver is "dsound".
SDL_AudioSpec:
  Format:   AUDIO_S16LSB
  Freq:     22050
  Samples:  512
  Channels: 2
Starting SDL audio callback...
SDL audio initialized.
----- Sound Info -----
    1 stereo
16384 samples
   16 samplebits
    1 submission_chunk
22050 speed
04890268 dma buffer
No background file.
----------------------
Sound initialization successful.
--------------------------------
Sound memory manager started
Loading vm file vm/ui.qvm...
...which has vmMagic VM_MAGIC_VER2
Loading 1124 jump table targets
VM file ui compiled to 682624 bytes of code
ui loaded in 2449088 bytes on the hunk
UI version: Smokin' Guns 1.1b1, 20091019, 00:16:07
Parsing menu file:ui/main.menu
Parsing menu file:ui/joinserver.menu
Parsing menu file:ui/skirmish.menu
Parsing menu file:ui/createserver.menu
Parsing menu file:ui/demo.menu
Parsing menu file:ui/connect.menu
Parsing menu file:ui/quitcredit.menu
Parsing menu file:ui/settings.menu
Parsing menu file:ui/settings_controls.menu
Parsing menu file:ui/settings_system.menu
Parsing menu file:ui/settings_options.menu
Parsing menu file:ui/settings_player.menu
Parsing menu file:ui/settings_default.menu
Parsing menu file:ui/pop_password.menu
Parsing menu file:ui/pop_findplayer.menu
Parsing menu file:ui/pop_serverinfo.menu
Parsing menu file:ui/pop_createfavorite.menu
Parsing menu file:ui/pop_specify.menu
Parsing menu file:ui/pop_multiplayer.menu
Parsing menu file:ui/pop_quit.menu
Parsing menu file:ui/pop_error.menu
Parsing menu file:ui/pop_vid_restart.menu
UI menu load time = 818 milli seconds
Parsing menu file:ui/ingame.menu
Parsing menu file:ui/ingame_vote.menu
Parsing menu file:ui/ingame_about.menu
Parsing menu file:ui/ingame_controls.menu
Parsing menu file:ui/ingame_join.menu
Parsing menu file:ui/ingame_joinred.menu
Parsing menu file:ui/ingame_joinblue.menu
Parsing menu file:ui/ingame_options.menu
Parsing menu file:ui/ingame_system.menu
Parsing menu file:ui/ingame_leave.menu
Parsing menu file:ui/ingame_player.menu
Parsing menu file:ui/ingame_bots.menu
Parsing menu file:ui/ingame_callvote.menu
UI menu load time = 290 milli seconds
Registering SG model: models/wq3_players/wq_female1/icon_blue
Registering SG model: models/wq3_players/wq_female1/icon_red
Registering SG model: models/wq3_players/wq_male1/icon_blue
Registering SG model: models/wq3_players/wq_male1/icon_red
Registering SG model: models/wq3_players/wq_male2/icon_blue
Registering SG model: models/wq3_players/wq_male2/icon_red
Registering SG model: models/wq3_players/wq_male3/icon_blue
Registering SG model: models/wq3_players/wq_male3/icon_red
8 bots parsed
--- Common Initialization Complete ---
Winsock Initialized
Hostname: Sucalakafufu
IP6: ::1
IP: 10.62.193.116
IP: 192.168.85.1
IP: 192.168.20.1
IP: 192.168.56.1
IP: 5.19.52.77
Opening IP6 socket: [::]:27960
Opening IP socket: 0.0.0.0:27960
SG Name: Sucalakafufu
Clan: [CWNN] - Clan With No Name
User avatar
Sucalakafufu
Gunslinger
 
Posts: 239
Joined: Thu Apr 16, 2009 8:59 am



Next

Return to Code

Show Sidebar
Show Sidebar

User Control Panel